pub struct Sample<T> {
pub value: T,
pub provenance: Provenance,
pub freshness: Freshness,
pub envelope: Envelope,
}Expand description
A signal value with its provenance, its freshness and its envelope.
Fields§
§value: TThe value. Never absent: the init value under Init, and the last good
value or the init value under Invalid.
provenance: ProvenanceWhere the value comes from.
freshness: FreshnessHow old the value is.
envelope: EnvelopeThe sender’s timestamp and sequence number.
Implementations§
Source§impl<T> Sample<T>
impl<T> Sample<T>
Sourcepub fn usable(&self) -> bool
pub fn usable(&self) -> bool
true when the provenance is Live and the freshness is not Stale.
Examples found in repository?
examples/read_sample.rs (line 385)
375fn main() {
376 let steps = [
377 "init",
378 "live",
379 "stale",
380 "declared invalid",
381 "detected invalid",
382 "corrupt",
383 ];
384 for (step, sample) in steps.iter().zip(walk()) {
385 println!("{step}: {sample:?} usable={}", sample.usable());
386 }
387}Trait Implementations§
impl<T: Copy> Copy for Sample<T>
impl<T: Eq> Eq for Sample<T>
impl<T: PartialEq> StructuralPartialEq for Sample<T>
Auto Trait Implementations§
impl<T> Freeze for Sample<T>where
T: Freeze,
impl<T> RefUnwindSafe for Sample<T>where
T: RefUnwindSafe,
impl<T> Send for Sample<T>where
T: Send,
impl<T> Sync for Sample<T>where
T: Sync,
impl<T> Unpin for Sample<T>where
T: Unpin,
impl<T> UnsafeUnpin for Sample<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Sample<T>where
T: UnwindSafe,
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