Struct openthread::ot::Timestamp

source ·
#[repr(transparent)]
pub struct Timestamp(pub u64);
Expand description

Type representing a Thread timestamp.

Tuple Fields§

§0: u64

Implementations§

source§

impl Timestamp

source

pub const EPOCH: Timestamp = _

Timestamp for the start of time.

source

pub fn now() -> Timestamp

Returns the timestamp representing this instant.

source

pub const fn is_authoritative(&self) -> bool

Returns true if this timestamp is authoritative, false otherwise.

source

pub fn set_authoritative(&mut self, authoritative: bool)

Sets or clears the authoritative bit.

source

pub fn with_authoritative(self, authoritative: bool) -> Self

Returns this timestamp with the authoritative bit changed as indicated.

source

pub fn try_from_system_time( system_time: SystemTime ) -> Result<Timestamp, BadSystemTime>

Tries to convert a std::time::SystemTime to a Timestamp.

Will fail if the given SystemTime cannot be represented as a Timestamp. This can happen if the SystemTime represents a time that is before the epoch or is too far in the future.

source

pub fn try_from_duration_since_epoch( duration: Duration ) -> Result<Timestamp, BadSystemTime>

Tries to convert a std::time::Duration to a Timestamp.

Will fail if duration is negative or too large.

source

pub const fn as_secs(&self) -> u64

Returns the timestamp as the number of seconds since the epoch.

source

pub const fn subsec_fraction(&self) -> u64

Returns the subsecond fraction of the timestamp, measured in 1/32768ths of a second.

source

pub const fn as_micros(&self) -> u64

Returns the timestamp as the number of microseconds since the epoch.

source

pub fn to_system_time(&self) -> SystemTime

Converts this Timestamp into a std::time::SystemTime;

source

pub fn to_duration_since_epoch(&self) -> Duration

Returns this timestamp as a duration since the UNIX epoch (1970-01-01T00:00:00UTC)

source

pub const fn to_be_bytes(&self) -> [u8; 8]

Returns the timestamp as big-endian bytes.

source

pub const fn to_le_bytes(&self) -> [u8; 8]

Returns the timestamp as little-endian bytes.

source

pub fn to_naive_date_time(&self) -> NaiveDateTime

Returns the timestamp as an instance of chrono::naive::NaiveDateTime.

Trait Implementations§

source§

impl Add<Duration> for Timestamp

§

type Output = Timestamp

The resulting type after applying the + operator.
source§

fn add(self, rhs: Duration) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<Duration> for Timestamp

source§

fn add_assign(&mut self, duration: Duration)

Performs the += operation. Read more
source§

impl Clone for Timestamp

source§

fn clone(&self) -> Timestamp

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Timestamp

source§

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

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

impl Default for Timestamp

source§

fn default() -> Timestamp

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

impl Display for Timestamp

source§

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

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

impl From<Timestamp> for SystemTime

source§

fn from(ts: Timestamp) -> Self

Converts to this type from the input type.
source§

impl From<Timestamp> for otTimestamp

source§

fn from(ts: Timestamp) -> Self

Converts to this type from the input type.
source§

impl From<Timestamp> for u64

source§

fn from(ts: Timestamp) -> Self

Converts to this type from the input type.
source§

impl From<otTimestamp> for Timestamp

source§

fn from(ts: otTimestamp) -> Self

Converts to this type from the input type.
source§

impl From<u64> for Timestamp

source§

fn from(ts: u64) -> Self

Converts to this type from the input type.
source§

impl Ord for Timestamp

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · source§

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

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

impl PartialEq for Timestamp

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Timestamp

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<SystemTime> for Timestamp

§

type Error = BadSystemTime

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

fn try_from(value: SystemTime) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Timestamp

source§

impl Eq for Timestamp

source§

impl StructuralPartialEq for Timestamp

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
§

impl<T> Encode<Ambiguous1> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T> Encode<Ambiguous2> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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§

default 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>,

§

type Error = Infallible

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>,

§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more