rl_tokio/
error.rs

1#[derive(Debug,PartialEq)]
2#[non_exhaustive]
3pub enum Error {
4	/// An unexpected error from rl-core.
5	///
6	/// Note: It probably doesn't make sense to handle specific errors here. In future versions rl-tokio may handle them itself, created dedicated error items or avoid triggering those codepaths. This variant mostly exists to avoid an allocation.
7	RlCore(rl_core::Denied<tokio::time::Instant>),
8
9	Timeout(rl_core::TooEarly<tokio::time::Instant>),
10
11	/// The request is larger than the max bucket size and will never be allowed with the current config.
12	///
13	/// Note: [Overfilling](Tracker::overfull()) can allow requests larger than buckets, however this never happens by waiting. It must be done explicitly by the application. Overfilling can allow arbitrarily large requests to succeed on any config.
14	TooBig,
15}
16
17impl std::fmt::Display for Error {
18	fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
19		match self {
20			Error::RlCore(err) => err.fmt(f),
21			Error::Timeout(too_early) => too_early.fmt(f),
22			Error::TooBig => rl_core::Denied::<tokio::time::Instant>::TooBig.fmt(f),
23		}
24	}
25}
26
27impl std::error::Error for Error {}