devela/phys/time/
error.rsuse crate::impl_error;
#[cfg(feature = "std")]
use crate::Duration;
#[cfg(feature = "std")]
use std::time::SystemTimeError as StdSystemTimeError;
impl_error! { individual:
#[cfg(feature = "std")]
#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "std")))]
pub struct SystemTimeError(Duration);
DOC_SYSTEM_TIME_ERROR =
"An 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)
}
#[cfg(feature = "std")]
#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "std")))]
impl From<StdSystemTimeError> for SystemTimeError {
fn from(from: StdSystemTimeError) -> Self {
SystemTimeError(from.duration())
}
}
#[cfg(all(feature = "error", feature = "time"))]
pub use full_composite::*;
#[cfg(all(feature = "error", feature = "time"))]
#[cfg_attr(feature = "nightly_doc", doc(cfg(all(feature = "error", feature = "time"))))]
mod full_composite {
use super::*;
use crate::{DataOverflow, DOC_DATA_OVERFLOW};
#[doc = crate::TAG_RESULT!()]
pub type TimeResult<T> = crate::Result<T, TimeError>;
impl_error! { composite: fmt(f)
#[non_exhaustive]
pub enum TimeError {
DOC_DATA_OVERFLOW:
DataOverflow(o|0: Option<usize>) => DataOverflow(*o),
#[cfg(feature = "std")]
#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "std")))]
DOC_SYSTEM_TIME_ERROR:
SystemTime(d|0: Duration) => SystemTimeError(*d),
}
}
}