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
impl Clone for EmbassyTimestampGenerator
Source§fn clone(&self) -> EmbassyTimestampGenerator
fn clone(&self) -> EmbassyTimestampGenerator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for EmbassyTimestampGenerator
impl Default for EmbassyTimestampGenerator
Source§impl NtpTimestampGenerator for EmbassyTimestampGenerator
impl NtpTimestampGenerator for EmbassyTimestampGenerator
Source§fn init(&mut self)
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
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
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).