rl_core/
too_early.rs

1/// The rate limit is not available at the requested time.
2///
3/// This isn't an "error" per se, but the rate limit is not available.
4#[derive(Clone,Debug,PartialEq,Eq,PartialOrd,Ord)]
5pub struct TooEarly<T = std::time::SystemTime> {
6	pub(crate) next: T,
7}
8
9impl<T: Clone> TooEarly<T> {
10	/// Return when the request will be allowed.
11	///
12	/// Returns the earliest time that the request can possibly succeed. If there are no other requests in the interim than retrying the same request will succeed at that time.
13	pub fn available_at(&self) -> T {
14		self.next.clone()
15	}
16}
17
18impl<T: std::fmt::Debug> std::fmt::Display for TooEarly<T> {
19	fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
20		write!(f, "Try again after {:?}", self.next)
21	}
22}
23
24impl<T: std::fmt::Debug> std::error::Error for TooEarly<T> {}