use crate::{_tags, Duration, StdSystemTimeError, define_error};
define_error! { individual:
pub struct SystemTimeError(Duration);
+location: "phys/time",
+tag: _tags!(time),
DOC_SYSTEM_TIME_ERROR =
"Returned from the `duration_since` and `elapsed` methods on `SystemTime`.\n\n
This is basically a replication of `std::time::`[`SystemTimeError`][StdSystemTimeError].",
self+f => write!(f, "SystemTimeError difference: {:?}", self.0)
}
#[rustfmt::skip]
impl From<StdSystemTimeError> for SystemTimeError {
fn from(from: StdSystemTimeError) -> Self { SystemTimeError(from.duration()) }
}
pub use full_composite::*;
mod full_composite {
use super::*;
use crate::{Boundary1d, CONST, MismatchedCapacity};
CONST! {
DOC_CAPACITY_MISMATCH = "The operation did not satisfy a finite capacity constraint.";
}
define_error! { composite: fmt(f)
#[doc = _tags!(time)]
#[doc = crate::_doc_location!("phys/time/source")]
#[cfg_attr(nightly_doc, doc(cfg(feature = "std")))]
#[non_exhaustive]
pub enum TimeError {
+tag: _tags!(time),
DOC_CAPACITY_MISMATCH: +const
Overflow {
bound: Boundary1d,
value: Option<usize>,
limit: Option<usize>
}
=> MismatchedCapacity { bound: *bound, value: *value, limit: *limit },
DOC_SYSTEM_TIME_ERROR: +const
SystemTime(d|0: Duration) => SystemTimeError(*d)
}
}
impl From<StdSystemTimeError> for TimeError {
fn from(from: StdSystemTimeError) -> Self {
TimeError::SystemTime(from.duration())
}
}
}