pub trait TimeInstant:
Copy
+ Clone
+ PartialEq
+ PartialOrd
+ Sized {
type Duration;
// Required methods
fn to_utc(&self) -> Option<DateTime<Utc>>;
fn from_utc(datetime: DateTime<Utc>) -> Self;
fn difference(&self, other: &Self) -> Self::Duration;
fn add_duration(&self, duration: Self::Duration) -> Self;
fn sub_duration(&self, duration: Self::Duration) -> Self;
}Expand description
Trait for types that represent a point in time.
Types implementing this trait can be used as time instants in Interval<T>
and provide conversions to/from UTC plus basic arithmetic operations.
Required Associated Types§
Required Methods§
Sourcefn difference(&self, other: &Self) -> Self::Duration
fn difference(&self, other: &Self) -> Self::Duration
Compute the difference between two time instants.
Sourcefn add_duration(&self, duration: Self::Duration) -> Self
fn add_duration(&self, duration: Self::Duration) -> Self
Add a duration to this time instant.
Sourcefn sub_duration(&self, duration: Self::Duration) -> Self
fn sub_duration(&self, duration: Self::Duration) -> Self
Subtract a duration from this time instant.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.