pub struct Guard { /* private fields */ }Implementations§
Source§impl Guard
impl Guard
pub fn new(config: GuardConfig) -> Guard
Sourcepub fn client(&self, peer: IpAddr, headers: &HeaderMap) -> IpAddr
pub fn client(&self, peer: IpAddr, headers: &HeaderMap) -> IpAddr
The client behind a connection from peer.
Sourcepub fn connect(&self, ip: IpAddr) -> Option<Connection<'_>>
pub fn connect(&self, ip: IpAddr) -> Option<Connection<'_>>
Opens a connection for ip; None if the client is at its cap or
over budget.
Sourcepub fn request(&self, ip: IpAddr, weight: u64) -> bool
pub fn request(&self, ip: IpAddr, weight: u64) -> bool
Counts a request; false if the client is over budget with it.
Sourcepub fn worked(&self, ip: IpAddr, spent: Duration)
pub fn worked(&self, ip: IpAddr, spent: Duration)
Counts the time a request of ip took to handle against its request
budget: one more request per work_ms. The next request over budget
gets slowDown.
pub fn sweep_every(&self) -> Option<Duration>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Guard
impl RefUnwindSafe for Guard
impl Send for Guard
impl Sync for Guard
impl Unpin for Guard
impl UnsafeUnpin for Guard
impl UnwindSafe for Guard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].