pub struct RateLimitPlugin { /* private fields */ }Expand description
Process-wide RateLimitPlugin registry storing policy, RateLimitStore, and KeyExtractor.
Implementations§
Source§impl RateLimitPlugin
Inherent implementation of RateLimitPlugin.
impl RateLimitPlugin
Inherent implementation of RateLimitPlugin.
Sourcepub fn init(policy: RateLimitPolicy) -> &'static Self
pub fn init(policy: RateLimitPolicy) -> &'static Self
Initializes the global RateLimitPlugin with the default 64-shard limiter and client-IP extractor.
§Arguments
RateLimitPolicy- Quota and algorithm policy.
§Returns
&'static Self- Reference to the initialized global plugin.
Sourcepub fn init_custom(
policy: RateLimitPolicy,
store: Arc<dyn RateLimitStore>,
key_extractor: Arc<dyn KeyExtractor>,
) -> &'static Self
pub fn init_custom( policy: RateLimitPolicy, store: Arc<dyn RateLimitStore>, key_extractor: Arc<dyn KeyExtractor>, ) -> &'static Self
Initializes the global RateLimitPlugin with custom RateLimitStore and KeyExtractor.
§Arguments
RateLimitPolicy- Quota header and exempt-path policy.Arc<dyn RateLimitStore>- Custom or distributed backend store.Arc<dyn KeyExtractor>- Custom partition key extractor.
§Returns
&'static Self- Reference to the initialized global plugin.
Sourcepub fn get() -> Option<&'static Self>
pub fn get() -> Option<&'static Self>
Returns the initialized global RateLimitPlugin, if initialized.
§Returns
Option<&'static Self>- Reference to the global plugin, orNone.
Sourcepub fn get_policy(&self) -> &RateLimitPolicy
pub fn get_policy(&self) -> &RateLimitPolicy
Sourcepub fn get_store(&self) -> &Arc<dyn RateLimitStore> ⓘ
pub fn get_store(&self) -> &Arc<dyn RateLimitStore> ⓘ
Returns the active Arc<dyn RateLimitStore>.
§Returns
&Arc<dyn RateLimitStore>- Active backend store.
Sourcepub fn get_key_extractor(&self) -> &Arc<dyn KeyExtractor> ⓘ
pub fn get_key_extractor(&self) -> &Arc<dyn KeyExtractor> ⓘ
Sourcepub fn evaluate_key(&self, key: &str, ctx: &mut Context) -> RateLimitDecision
pub fn evaluate_key(&self, key: &str, ctx: &mut Context) -> RateLimitDecision
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RateLimitPlugin
impl !UnwindSafe for RateLimitPlugin
impl Forget for RateLimitPlugin
impl Freeze for RateLimitPluginwhere
*const u8 is !null: Freeze,
PhantomData<String>: Freeze,
*const ArcInner<dyn RateLimitStore> is !null: Freeze,
PhantomData<ArcInner<dyn RateLimitStore>>: Freeze,
*const ArcInner<ShardedRateLimiterInner> is !null: Freeze,
PhantomData<ArcInner<ShardedRateLimiterInner>>: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<dyn KeyExtractor> is !null: Freeze,
PhantomData<ArcInner<dyn KeyExtractor>>: Freeze,
impl Move for RateLimitPlugin
impl Send for RateLimitPluginwhere
RawVecInner: Send,
Arc<dyn RateLimitStore>: Send,
Arc<ShardedRateLimiterInner>: Send,
Arc<dyn KeyExtractor>: Send,
impl Sync for RateLimitPluginwhere
RawVecInner: Sync,
Arc<dyn RateLimitStore>: Sync,
Arc<ShardedRateLimiterInner>: Sync,
Arc<dyn KeyExtractor>: Sync,
impl Unpin for RateLimitPlugin
impl UnsafeUnpin for RateLimitPluginwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const ArcInner<dyn RateLimitStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn RateLimitStore>>: UnsafeUnpin,
*const ArcInner<ShardedRateLimiterInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<ShardedRateLimiterInner>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<dyn KeyExtractor> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn KeyExtractor>>: UnsafeUnpin,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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