Struct sntpc::NtpResult

source ·
pub struct NtpResult {
    pub seconds: u32,
    pub seconds_fraction: u32,
    pub roundtrip: u64,
    pub offset: i64,
    pub stratum: u8,
    pub precision: i8,
}
Expand description

SNTP request result representation

Fields§

§seconds: u32

NTP server seconds value

§seconds_fraction: u32

NTP server seconds fraction value

§roundtrip: u64

Request roundtrip time in microseconds

§offset: i64

Estimated difference between the NTP reference and the system time in microseconds

§stratum: u8

Clock stratum of NTP server

§precision: i8

Precision of NTP server as log2(seconds) - this should usually be negative

Implementations§

source§

impl NtpResult

source

pub fn new( seconds: u32, seconds_fraction: u32, roundtrip: u64, offset: i64, stratum: u8, precision: i8 ) -> Self

Create new NTP result Args:

  • seconds - number of seconds
  • seconds_fraction - number of seconds fraction
  • roundtrip - calculated roundtrip in microseconds
  • offset - calculated system clock offset in microseconds
  • stratum - integer indicating the stratum (level of server’s hierarchy to stratum 0 - “reference clock”)
  • precision - an exponent of two, where the resulting value is the precision of the system clock in seconds
source

pub fn sec(&self) -> u32

Returns number of seconds reported by an NTP server

source

pub fn sec_fraction(&self) -> u32

Returns number of seconds fraction reported by an NTP server

source

pub fn roundtrip(&self) -> u64

Returns request’s roundtrip time (client -> server -> client) in microseconds

source

pub fn offset(&self) -> i64

Returns system clock offset value in microseconds

source

pub fn stratum(&self) -> u8

Returns reported stratum value (level of server’s hierarchy to stratum 0 - “reference clock”)

source

pub fn precision(&self) -> i8

Returns reported precision value (an exponent of two, which results in the precision of server’s system clock in seconds)

Trait Implementations§

source§

impl Debug for NtpResult

source§

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

Formats the value using the given formatter. 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<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>,

§

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.