pub struct Observed<T, U = ()> { /* private fields */ }Expand description
Value with its observation time and quality.
T is the value; U the uncertainty type (see Quality). Transparent to
the value (Observed::value, Observed::map); answers age and
staleness.
Implementations§
Source§impl<T, U> Observed<T, U>
impl<T, U> Observed<T, U>
Sourcepub const fn new(value: T, taken_at: Instant<Utc>, quality: Quality<U>) -> Self
pub const fn new(value: T, taken_at: Instant<Utc>, quality: Quality<U>) -> Self
Wraps a value with its time and quality.
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Unwraps the value.
Sourcepub fn age_at(&self, now: Instant<Utc>) -> Result<Duration>
pub fn age_at(&self, now: Instant<Utc>) -> Result<Duration>
Age at now.
Computed, never stored.
§Errors
KernelError::TimeReversed if now
precedes the observation (clock stepped back, or a future timestamp).
Sourcepub fn is_stale_at(&self, now: Instant<Utc>, limit: Duration) -> bool
pub fn is_stale_at(&self, now: Instant<Utc>, limit: Duration) -> bool
Whether older than limit at now.
false for a reading timestamped after now; that error is reported by
Observed::age_at.
Trait Implementations§
impl<T: Copy, U: Copy> Copy for Observed<T, U>
impl<T: PartialEq, U: PartialEq> StructuralPartialEq for Observed<T, U>
Auto Trait Implementations§
impl<T, U> Freeze for Observed<T, U>
impl<T, U> RefUnwindSafe for Observed<T, U>
impl<T, U> Send for Observed<T, U>
impl<T, U> Sync for Observed<T, U>
impl<T, U> Unpin for Observed<T, U>
impl<T, U> UnsafeUnpin for Observed<T, U>
impl<T, U> UnwindSafe for Observed<T, U>
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