#[non_exhaustive]pub enum ThrottleError {
CostExceedsCapacity {
cost: u32,
capacity: u32,
},
}Available on crate feature
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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
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.
Trait Implementations§
Source§impl Clone for ThrottleError
impl Clone for ThrottleError
Source§fn clone(&self) -> ThrottleError
fn clone(&self) -> ThrottleError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
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
Returns true if the operation can be retried
Source§fn is_fatal(&self) -> bool
fn is_fatal(&self) -> bool
Returns true if the error is fatal and should terminate the program
Source§fn status_code(&self) -> u16
fn status_code(&self) -> u16
Returns an appropriate HTTP status code for the error
Source§fn user_message(&self) -> String
fn user_message(&self) -> String
Returns a user-facing message that can be shown to end users
Source§fn dev_message(&self) -> String
fn dev_message(&self) -> String
Returns a detailed technical message for developers/logs
Source§impl PartialEq for ThrottleError
impl PartialEq for ThrottleError
Source§fn eq(&self, other: &ThrottleError) -> bool
fn eq(&self, other: &ThrottleError) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ThrottleError
Auto Trait Implementations§
impl Freeze for ThrottleError
impl RefUnwindSafe for ThrottleError
impl Send for ThrottleError
impl Sync for ThrottleError
impl Unpin for ThrottleError
impl UnsafeUnpin for ThrottleError
impl UnwindSafe for ThrottleError
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ForgeErrorRecovery for Twhere
T: ForgeError,
impl<T> ForgeErrorRecovery for Twhere
T: ForgeError,
Source§fn create_retry_policy(&self, max_retries: usize) -> RetryPolicy
fn create_retry_policy(&self, max_retries: usize) -> RetryPolicy
Create a retry policy optimized for this error type
Source§fn retry<F, T, E>(&self, max_retries: usize, operation: F) -> Result<T, E>
fn retry<F, T, E>(&self, max_retries: usize, operation: F) -> Result<T, E>
Execute a fallible operation with retries if this error type is retryable
Source§fn create_circuit_breaker(&self, name: impl Into<String>) -> CircuitBreaker
fn create_circuit_breaker(&self, name: impl Into<String>) -> CircuitBreaker
Create a circuit breaker for operations that might result in this error type