pub struct LayeredBuilder<K, E = K>{ /* private fields */ }Available on crate feature
std only.Expand description
Builder for a Layered limiter.
Set any subset of the three scopes; omitted scopes simply do not constrain.
§Examples
use throttle_net::{Layered, PerKey, Throttle};
let layered = Layered::<u64, String>::builder()
.global(Throttle::per_second(1000))
.per_key(PerKey::per_second(100)) // keyed by numeric tenant id
.build();Implementations§
Source§impl<K, E> LayeredBuilder<K, E>
impl<K, E> LayeredBuilder<K, E>
Sourcepub fn per_key<C>(self, limiter: PerKey<K, C>) -> Self
pub fn per_key<C>(self, limiter: PerKey<K, C>) -> Self
Sets the per-key scope: independent state per caller key. Accepts a
PerKey built on any clock.
Sourcepub fn per_endpoint<C>(self, limiter: PerKey<E, C>) -> Self
pub fn per_endpoint<C>(self, limiter: PerKey<E, C>) -> Self
Sets the per-endpoint scope: independent state per endpoint. Accepts a
PerKey built on any clock.
Auto Trait Implementations§
impl<K, E = K> !RefUnwindSafe for LayeredBuilder<K, E>
impl<K, E = K> !UnwindSafe for LayeredBuilder<K, E>
impl<K, E> Freeze for LayeredBuilder<K, E>
impl<K, E> Send for LayeredBuilder<K, E>
impl<K, E> Sync for LayeredBuilder<K, E>
impl<K, E> Unpin for LayeredBuilder<K, E>
impl<K, E> UnsafeUnpin for LayeredBuilder<K, E>
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