#[non_exhaustive]pub enum ThrottleError {
CostExceedsCapacity {
cost: u32,
capacity: u32,
},
CircuitOpen {
retry_after: Duration,
},
QueueFull,
DeadlineExceeded,
}std only.Expand description
An acquisition that cannot complete.
The enum is #[non_exhaustive]: later phases introduce new failure modes
(deadlines, a tripped circuit breaker, a closed limiter), so a match on it
must include a wildcard arm.
§Examples
use throttle_net::{Throttle, ThrottleError};
// Capacity is 5; asking for 9 can never be satisfied.
let throttle = Throttle::per_second(5);
let err = throttle.acquire_with_cost(9).await.unwrap_err();
assert!(matches!(err, ThrottleError::CostExceedsCapacity { cost: 9, capacity: 5 }));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
CostExceedsCapacity
The requested cost is larger than the limiter’s capacity, so the bucket can never hold enough tokens to grant it. Reduce the cost or raise the limiter’s capacity. This is a configuration mismatch, not a transient condition, so it is not retryable.
Fields
CircuitOpen
A circuit breaker is open and shed this request without touching the wrapped limiter. The breaker is failing fast to give the downstream time to recover; retry once it has had a chance to close again. This is retryable, after the suggested wait.
Fields
retry_after: DurationHow long until the breaker is expected to allow a trial request
(move to half-open). Duration::ZERO
means it may already be admitting a trial.
QueueFull
A bounded queue was full and its overflow policy rejected this request. Transient — capacity may free up — so it is retryable.
DeadlineExceeded
A queued request’s deadline passed before it could be served. Not retryable as-is: the deadline is in the past.
Trait Implementations§
Source§impl Clone for ThrottleError
impl Clone for ThrottleError
Source§fn clone(&self) -> ThrottleError
fn clone(&self) -> ThrottleError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ThrottleError
Source§impl Debug for ThrottleError
impl Debug for ThrottleError
Source§impl Display for ThrottleError
impl Display for ThrottleError
impl Eq for ThrottleError
Source§impl Error for ThrottleError
impl Error for ThrottleError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl ForgeError for ThrottleError
impl ForgeError for ThrottleError
Source§fn is_retryable(&self) -> bool
fn is_retryable(&self) -> bool
Source§fn is_fatal(&self) -> bool
fn is_fatal(&self) -> bool
Source§fn status_code(&self) -> u16
fn status_code(&self) -> u16
Source§fn user_message(&self) -> String
fn user_message(&self) -> String
Source§fn dev_message(&self) -> String
fn dev_message(&self) -> String
Source§impl PartialEq for ThrottleError
impl PartialEq for ThrottleError
Source§fn eq(&self, other: &ThrottleError) -> bool
fn eq(&self, other: &ThrottleError) -> bool
self and other values to be equal, and is used by ==.