pub struct Throttle { /* private fields */ }Expand description
Request throttling primitives. The global request-throttling service.
Implementations§
Source§impl Throttle
impl Throttle
Sourcepub fn new(options: ThrottleOptions) -> Result<Self>
pub fn new(options: ThrottleOptions) -> Result<Self>
Creates a throttle service from application options.
Sourcepub async fn check(
&self,
context: &RequestContext,
method: &str,
route: &str,
policy: ThrottlePolicy,
) -> Result<Option<HttpResponse>>
pub async fn check( &self, context: &RequestContext, method: &str, route: &str, policy: ThrottlePolicy, ) -> Result<Option<HttpResponse>>
Checks and increments the quota, returning a response only when rejected.
Sourcepub fn policy(&self) -> ThrottlePolicy
pub fn policy(&self) -> ThrottlePolicy
Returns the configured global policy.
Trait Implementations§
Source§impl Injectable for Throttle
impl Injectable for Throttle
Source§fn dependencies() -> Vec<ProviderDependency>
fn dependencies() -> Vec<ProviderDependency>
Dependencies resolved while constructing this provider. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for Throttle
impl !UnwindSafe for Throttle
impl Freeze for Throttle
impl Send for Throttle
impl Sync for Throttle
impl Unpin for Throttle
impl UnsafeUnpin for Throttle
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