pub trait NtpTimestampGenerator {
    // Required methods
    fn init(&mut self);
    fn timestamp_sec(&self) -> u64;
    fn timestamp_subsec_micros(&self) -> u32;
}
Expand description

A trait encapsulating timestamp generator’s operations

Since under no_std environment time::now() implementations may be not available, you can implement that trait on an object you want and provide proper system timestamps for the SNTP client. According to specs, all timestamps calculated from UNIX EPOCH “1970-01-01 00:00:00 UTC

Required Methods§

source

fn init(&mut self)

Initialize timestamp generator state with now system time since UNIX EPOCH. Expected to be called every time before timestamp_sec and timestamp_subsec_micros usage. Basic flow would be the following:

# Timestamp A required
init()
timestamp_sec()
timestamp_subsec_micros()
// ...
# Timestamp B required
init()
timestamp_sec()
timestamp_subsec_micros()
// ... so on
source

fn timestamp_sec(&self) -> u64

Returns timestamp in seconds since UNIX EPOCH for the initialized generator

source

fn timestamp_subsec_micros(&self) -> u32

Returns the fractional part of the timestamp in whole micro seconds. That method should not return microseconds since UNIX EPOCH

Implementors§