Skip to main content

TaiTimestamp

Struct TaiTimestamp 

Source
pub struct TaiTimestamp(/* private fields */);
Expand description

A point on International Atomic Time, in nanoseconds since 1970-01-01T00:00:00 TAI.

TAI never steps for a leap second, which is why PTP keeps it, and runs ahead of UTC by every leap second since 1972. The offset between them is the one the kernel holds, which a time service sets, so a TaiTimestamp never mixes with a Timestamp. It is written as RFC 3339’s date and time in the zone TAI, and parses back from it.

§Examples

use t2t_core::{TaiTimestamp, Timedelta};

let synced: TaiTimestamp = "2026-09-16T07:46:12.5 TAI".parse()?;
let next = synced + Timedelta::from_millis(500);

assert_eq!(next.to_string(), "2026-09-16T07:46:13.000000000 TAI", "half a second on");

Implementations§

Source§

impl TaiTimestamp

Source

pub const MIN: Self

The earliest point the count holds.

Source

pub const MAX: Self

The latest point the count holds.

Source

pub const fn checked_add(self, span: Timedelta) -> Option<Self>

The point span later, or None past the range.

Source

pub const fn checked_sub(self, span: Timedelta) -> Option<Self>

The point span earlier, or None past the range.

Source

pub const fn checked_since(self, start: Self) -> Option<Timedelta>

The span since start, or None past the span’s range.

Source

pub const fn floor(self, unit: Timedelta) -> Self

The nearest multiple of |unit| at or below the point, or the point for a zero unit.

Source

pub const fn ceil(self, unit: Timedelta) -> Self

The nearest multiple of |unit| at or above the point, or the point for a zero unit.

Source§

impl TaiTimestamp

Source

pub const fn from_nanos(nanos: i64) -> Self

The point nanos nanoseconds after 1970-01-01T00:00:00 TAI.

Source

pub const fn from_micros(micros: i64) -> Self

The point micros microseconds after 1970-01-01T00:00:00 TAI, saturating.

Source

pub const fn from_millis(millis: i64) -> Self

The point millis milliseconds after 1970-01-01T00:00:00 TAI, saturating.

Source

pub const fn from_secs(secs: i64) -> Self

The point secs seconds after 1970-01-01T00:00:00 TAI, saturating.

Source

pub const fn as_nanos(self) -> i64

Nanoseconds since 1970-01-01T00:00:00 TAI.

Source

pub const fn as_micros(self) -> i64

Whole microseconds since 1970-01-01T00:00:00 TAI, rounded down.

Source

pub const fn as_millis(self) -> i64

Whole milliseconds since 1970-01-01T00:00:00 TAI, rounded down.

Source

pub const fn as_secs(self) -> i64

Whole seconds since 1970-01-01T00:00:00 TAI, rounded down.

Trait Implementations§

Source§

impl Add<Timedelta> for TaiTimestamp

Saturates at MIN and MAX.

Source§

type Output = TaiTimestamp

The resulting type after applying the + operator.
Source§

fn add(self, span: Timedelta) -> Self

Performs the + operation. Read more
Source§

impl AddAssign<Timedelta> for TaiTimestamp

Saturates at MIN and MAX.

Source§

fn add_assign(&mut self, span: Timedelta)

Performs the += operation. Read more
Source§

impl Clone for TaiTimestamp

Source§

fn clone(&self) -> Self

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 Copy for TaiTimestamp

Source§

impl Debug for TaiTimestamp

Source§

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

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

impl Default for TaiTimestamp

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TaiTimestamp

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

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

impl Display for TaiTimestamp

RFC 3339’s date and time, in the zone TAI: 2026-09-16T07:46:12.123456789 TAI.

The precision chooses the fraction’s digits, and a width pads the spelling, as for a Timestamp.

Source§

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

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

impl Eq for TaiTimestamp

Source§

impl FromBytes for TaiTimestamp
where i64: FromBytes,

Available on crate feature zerocopy only.
Source§

fn ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: KnownLayout + Immutable,

Interprets the given source as a &Self. Read more
Source§

fn ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: KnownLayout + Immutable,

Interprets the prefix of the given source as a &Self without copying. Read more
Source§

fn ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, !>>
where Self: Immutable + KnownLayout,

Interprets the suffix of the given bytes as a &Self. Read more
Source§

fn mut_from_bytes( source: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout,

Interprets the given source as a &mut Self. Read more
Source§

fn mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout,

Interprets the prefix of the given source as a &mut Self without copying. Read more
Source§

fn mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, !>>
where Self: IntoBytes + KnownLayout,

Interprets the suffix of the given source as a &mut Self without copying. Read more
Source§

fn read_from_bytes(source: &[u8]) -> Result<Self, SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the given source. Read more
Source§

fn read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the prefix of the given source. Read more
Source§

fn read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the suffix of the given source. Read more
Source§

fn read_from_io<R>(src: R) -> Result<Self, Error>
where Self: Sized, R: Read,

Available on crate feature std only.
Reads a copy of self from an io::Read. Read more
Source§

impl FromStr for TaiTimestamp

Reads what Display writes: RFC 3339’s date and time as a Timestamp reads them, then the zone TAI.

Source§

type Err = ParseTaiTimestampError

The associated error which can be returned from parsing.
Source§

fn from_str(text: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromZeros for TaiTimestamp
where i64: FromZeros,

Available on crate feature zerocopy only.
Source§

fn zero(&mut self)

Overwrites self with zeros. Read more
Source§

fn new_zeroed() -> Self
where Self: Sized,

Creates an instance of Self from zeroed bytes. Read more
Source§

fn new_box_zeroed() -> Result<Box<Self>, AllocError>
where Self: Sized,

Available on crate features alloc only.
Creates a Box<Self> from zeroed bytes. Read more
Source§

fn new_vec_zeroed(len: usize) -> Result<Vec<Self>, AllocError>
where Self: Sized,

Available on crate feature alloc only.
Creates a Vec<Self> from zeroed bytes. Read more
Source§

fn extend_vec_zeroed( v: &mut Vec<Self>, additional: usize, ) -> Result<(), AllocError>
where Self: Sized,

Available on crate feature alloc and non-no_zerocopy_panic_in_const_and_vec_try_reserve_1_57_0 only.
Extends a Vec<Self> by pushing additional new items onto the end of the vector. The new items are initialized with zeros.
Source§

fn insert_vec_zeroed( v: &mut Vec<Self>, position: usize, additional: usize, ) -> Result<(), AllocError>
where Self: Sized,

Available on crate feature alloc and non-no_zerocopy_panic_in_const_and_vec_try_reserve_1_57_0 only.
Inserts additional new items into Vec<Self> at position. The new items are initialized with zeros. Read more
Source§

impl Hash for TaiTimestamp

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Immutable for TaiTimestamp
where i64: Immutable,

Available on crate feature zerocopy only.
Source§

impl IntoBytes for TaiTimestamp
where i64: IntoBytes,

Available on crate feature zerocopy only.
Source§

fn as_bytes(&self) -> &[u8] ⓘ
where Self: Immutable,

Gets the bytes of this value. Read more
Source§

fn as_mut_bytes(&mut self) -> &mut [u8] ⓘ
where Self: FromBytes,

Gets the bytes of this value mutably. Read more
Source§

fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to dst. Read more
Source§

fn write_to_prefix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the prefix of dst. Read more
Source§

fn write_to_suffix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the suffix of dst. Read more
Source§

fn write_to_io<W>(&self, dst: W) -> Result<(), Error>
where Self: Immutable, W: Write,

Available on crate feature std only.
Writes a copy of self to an io::Write. Read more
Source§

impl JsonSchema for TaiTimestamp

Available on crate features schemars and serde only.
Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn json_schema(_generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl KnownLayout for TaiTimestamp
where Self: Sized,

Available on crate feature zerocopy only.
Source§

type PointerMetadata = ()

The type of metadata stored in a pointer to Self. Read more
Source§

fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>

Computes the size of an object of type Self with the given pointer metadata. Read more
Source§

impl Ord for TaiTimestamp

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for TaiTimestamp

Source§

fn eq(&self, other: &Self) -> bool

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for TaiTimestamp

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for TaiTimestamp

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

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

impl StructuralPartialEq for TaiTimestamp

Source§

impl Sub for TaiTimestamp

The span since the other point, saturating at the span’s range.

Source§

type Output = Timedelta

The resulting type after applying the - operator.
Source§

fn sub(self, start: Self) -> Timedelta

Performs the - operation. Read more
Source§

impl Sub<Timedelta> for TaiTimestamp

Saturates at MIN and MAX.

Source§

type Output = TaiTimestamp

The resulting type after applying the - operator.
Source§

fn sub(self, span: Timedelta) -> Self

Performs the - operation. Read more
Source§

impl SubAssign<Timedelta> for TaiTimestamp

Saturates at MIN and MAX.

Source§

fn sub_assign(&mut self, span: Timedelta)

Performs the -= operation. Read more
Source§

impl TimePoint for TaiTimestamp

Source§

type Span = Timedelta

The span between two points.
Source§

fn from_count(count: i64) -> Self

The point count units after the origin.
Source§

fn count(self) -> i64

The point’s count of units since the origin.
Source§

impl TryFromBytes for TaiTimestamp

Available on crate feature zerocopy only.
Source§

fn try_ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the given source as a &Self. Read more
Source§

fn try_ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the prefix of the given source as a &Self. Read more
Source§

fn try_ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the suffix of the given source as a &Self. Read more
Source§

fn try_mut_from_bytes( bytes: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the given source as a &mut Self without copying. Read more
Source§

fn try_mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the prefix of the given source as a &mut Self. Read more
Source§

fn try_mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the suffix of the given source as a &mut Self. Read more
Source§

fn try_read_from_bytes( source: &[u8], ) -> Result<Self, ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read the given source as a Self. Read more
Source§

fn try_read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the prefix of the given source. Read more
Source§

fn try_read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the suffix of the given source. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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<A, T> Read<A, BecauseImmutable> for T
where A: Aliasing, T: Immutable + ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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, !>

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.