#[non_exhaustive]pub enum DurationError {
OutOfRange,
MismatchedSigns,
Deserialize(Box<dyn Error + Send + Sync>),
}Expand description
Represent failures in converting or creating Duration instances.
§Examples
let duration = Duration::new(Duration::MAX_SECONDS + 2, 0);
assert!(matches!(duration, Err(DurationError::OutOfRange)));
let duration = Duration::new(0, 1_500_000_000);
assert!(matches!(duration, Err(DurationError::OutOfRange)));
let duration = Duration::new(120, -500_000_000);
assert!(matches!(duration, Err(DurationError::MismatchedSigns)));
let ts = Duration::try_from("invalid");
assert!(matches!(ts, Err(DurationError::Deserialize(_))));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.
OutOfRange
One of the components (seconds and/or nanoseconds) was out of range.
MismatchedSigns
The sign of the seconds component does not match the sign of the nanoseconds component.
Deserialize(Box<dyn Error + Send + Sync>)
Cannot deserialize the duration.
Trait Implementations§
Source§impl Debug for DurationError
impl Debug for DurationError
Source§impl Display for DurationError
impl Display for DurationError
Source§impl Error for DurationError
impl Error for DurationError
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()
Auto Trait Implementations§
impl Freeze for DurationError
impl !RefUnwindSafe for DurationError
impl Send for DurationError
impl Sync for DurationError
impl Unpin for DurationError
impl !UnwindSafe for DurationError
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