pub struct RateLimiter<A: Address, T, TargetRoute: DeliveryRoute<Protocol: Protocol<Addr = A, Msg = T>>, ReplyRoute: DeliveryRoute<Protocol: Protocol<Addr = A, Msg = RateLimiterOutcome<T>>>> { /* private fields */ }Expand description
Deterministic explicit-token admission behavior.
Admission atomically subtracts a positive cost and emits the value, or
returns ownership with an exhaustive rejection. Typed refill observations
saturate at capacity and cannot overflow. The initial count may be zero but
cannot exceed positive capacity. Initialization is empty, no actors are
created, and the host never terminates by policy. Token arithmetic,
saturation, and rejection ordering are Bombay policy. Clock cadence is not
observed here: a Periodic composition or Environment adapter supplies
typed Refill events. No transition has a semantic panic condition.
Implementations§
Source§impl<A, T, TargetRoute, ReplyRoute> RateLimiter<A, T, TargetRoute, ReplyRoute>where
A: Address,
TargetRoute: DeliveryRoute<Protocol: Protocol<Addr = A, Msg = T>>,
ReplyRoute: DeliveryRoute<Protocol: Protocol<Addr = A, Msg = RateLimiterOutcome<T>>>,
impl<A, T, TargetRoute, ReplyRoute> RateLimiter<A, T, TargetRoute, ReplyRoute>where
A: Address,
TargetRoute: DeliveryRoute<Protocol: Protocol<Addr = A, Msg = T>>,
ReplyRoute: DeliveryRoute<Protocol: Protocol<Addr = A, Msg = RateLimiterOutcome<T>>>,
Sourcepub fn new(
capacity: TokenCount,
initial: u64,
) -> Result<Self, RateLimiterConfigError>
pub fn new( capacity: TokenCount, initial: u64, ) -> Result<Self, RateLimiterConfigError>
Construct one explicit positive-capacity bucket.
§Errors
Returns RateLimiterConfigError::InitialExceedsCapacity when invalid.
Sourcepub const fn state(&self) -> RateLimiterState
pub const fn state(&self) -> RateLimiterState
Return complete current capacity and token state.