Skip to main content

Stamp

Enum Stamp 

Source
pub enum Stamp<T = Timestamp>
where T: TimePoint,
{ Static, At(T), }
Expand description

When a transform is valid: at one instant, or for all time.

Stamp is what Transform::timestamp returns and what its constructors take: a dynamic sample carries Stamp::At(t), a fixed relationship such as a sensor mount carries Stamp::Static. Staticness is a separate variant rather than a reserved timestamp value, so every instant the clock can produce — including t = 0 on boot-relative clocks — is ordinary dynamic data.

§Examples

use transforms::time::{Stamp, Timestamp};

let dynamic: Stamp = Stamp::At(Timestamp::zero());
let fixed: Stamp = Stamp::Static;

assert!(!dynamic.is_static());
assert!(fixed.is_static());
assert_eq!(dynamic.at(), Some(Timestamp::zero()));
assert_eq!(fixed.at(), None);

Stamp is deliberately not ordered. Static denotes all time rather than an instant, so it has no position on a time axis; a derived ordering would place it below every real instant and make the natural freshest-sample idiom (max_by_key(|tf| tf.timestamp)) rank an eternal transform as older than the epoch. Order the instants themselves — via Stamp::at — and decide what static means for the comparison at hand.

With the optional serde feature, Stamp serializes as an explicitly tagged enum: Stamp::At(t) as {"At": t} and Stamp::Static as "Static" in JSON, and as a variant index followed by the payload in non-self-describing formats. No timestamp value is reserved, and neither an absent nor a null timestamp field decodes — a message that lost its stamp is an error, never an eternal static transform.

Variants§

§

Static

Valid for all time: a fixed frame relationship that never expires.

§

At(T)

Valid at one instant.

Implementations§

Source§

impl<T> Stamp<T>
where T: TimePoint,

Source

pub const fn is_static(&self) -> bool

Returns true for Stamp::Static.

Source

pub const fn at(self) -> Option<T>

Returns the instant for Stamp::At, or None for Stamp::Static.

Trait Implementations§

Source§

impl<T> Clone for Stamp<T>
where T: TimePoint + Clone,

Source§

fn clone(&self) -> Stamp<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for Stamp<T>
where T: TimePoint + Copy,

Source§

impl<T> Debug for Stamp<T>
where T: TimePoint + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for Stamp<T>
where T: TimePoint + Deserialize<'de>,

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Eq for Stamp<T>
where T: TimePoint + Eq,

Source§

impl<T> PartialEq for Stamp<T>
where T: TimePoint + PartialEq,

Source§

fn eq(&self, other: &Stamp<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T> Serialize for Stamp<T>
where T: TimePoint + Serialize,

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> StructuralPartialEq for Stamp<T>
where T: TimePoint + PartialEq,

Auto Trait Implementations§

§

impl<T> Freeze for Stamp<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Stamp<T>
where T: RefUnwindSafe,

§

impl<T> Send for Stamp<T>
where T: Send,

§

impl<T> Sync for Stamp<T>
where T: Sync,

§

impl<T> Unpin for Stamp<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Stamp<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Stamp<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.