Skip to main content

EmbassyTimestampGenerator

Struct EmbassyTimestampGenerator 

Source
pub struct EmbassyTimestampGenerator { /* private fields */ }
Expand description

Monotonic timestamp generator backed by embassy_time::Instant.

This type implements NtpTimestampGenerator by capturing the current monotonic time via Instant::now on each call to init, then reporting the elapsed seconds and sub-second microseconds.

It does not provide wall-clock time. Instead, it provides a monotonic timestamp source suitable for SNTP round-trip delay calculations, where only the relative elapsed time between request and response matters.

§Example

use sntpc::NtpContext;
use sntpc_time_embassy::EmbassyTimestampGenerator;

let ntp_context = NtpContext::new(EmbassyTimestampGenerator::default());

Trait Implementations§

Source§

impl Clone for EmbassyTimestampGenerator

Source§

fn clone(&self) -> EmbassyTimestampGenerator

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 Default for EmbassyTimestampGenerator

Source§

fn default() -> Self

Returns a default EmbassyTimestampGenerator with the instant set to the epoch.

The instant is initialized to Instant::from_secs(0) and will be updated to the current time when init is called before each timestamp measurement.

Source§

impl NtpTimestampGenerator for EmbassyTimestampGenerator

Source§

fn init(&mut self)

Captures the current monotonic time from embassy_time::Instant::now.

This method should be called before each pair of timestamp_sec and timestamp_subsec_micros calls to ensure the timestamp reflects the current moment.

Source§

fn timestamp_sec(&self) -> u64

Returns the whole seconds component of the captured monotonic instant.

The value represents seconds elapsed since the Embassy runtime’s monotonic clock epoch, not since the UNIX epoch.

Source§

fn timestamp_subsec_micros(&self) -> u32

Returns the sub-second microsecond component of the captured monotonic instant.

This is the fractional part of the timestamp in whole microseconds (i.e., microseconds within the current second, in the range 0..1_000_000).

Source§

impl Copy for EmbassyTimestampGenerator

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<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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.