Clock

Trait Clock 

Source
pub trait Clock {
    type Error: Error;

    // Required methods
    fn now(&self) -> Result<Timestamp, Self::Error>;
    fn resolution(&self) -> Result<Timestamp, Self::Error>;
    fn set_frequency(&self, frequency: f64) -> Result<Timestamp, Self::Error>;
    fn get_frequency(&self) -> Result<f64, Self::Error>;
    fn step_clock(&self, offset: TimeOffset) -> Result<Timestamp, Self::Error>;
    fn set_leap_seconds(
        &self,
        leap_status: LeapIndicator,
    ) -> Result<(), Self::Error>;
    fn disable_kernel_ntp_algorithm(&self) -> Result<(), Self::Error>;
    fn set_tai(&self, tai_offset: i32) -> Result<(), Self::Error>;
    fn get_tai(&self) -> Result<i32, Self::Error>;
    fn error_estimate_update(
        &self,
        estimated_error: Duration,
        maximum_error: Duration,
    ) -> Result<(), Self::Error>;
}
Expand description

Trait for reading information from and modifying an OS clock

Required Associated Types§

Required Methods§

Source

fn now(&self) -> Result<Timestamp, Self::Error>

Get the current time.

Source

fn resolution(&self) -> Result<Timestamp, Self::Error>

Get the clock’s resolution.

The output Timestamp will be all zeros when the resolution is unavailable.

Source

fn set_frequency(&self, frequency: f64) -> Result<Timestamp, Self::Error>

Change the frequency of the clock. Returns the time at which the change was applied.

The unit of the input is milliseconds (of drift) per second, compared to the “natural” frequency of the clock.

Source

fn get_frequency(&self) -> Result<f64, Self::Error>

Get the frequency of the clock The unit of the output is milliseconds (of drift) per second, compared to the “natural” frequency of the clock.

Source

fn step_clock(&self, offset: TimeOffset) -> Result<Timestamp, Self::Error>

Change the current time of the clock by an offset. Returns the time at which the change was applied.

Source

fn set_leap_seconds( &self, leap_status: LeapIndicator, ) -> Result<(), Self::Error>

Change the indicators for upcoming leap seconds.

Source

fn disable_kernel_ntp_algorithm(&self) -> Result<(), Self::Error>

Disable all standard NTP kernel clock discipline. It is all your responsibility now.

The disabled settings are:

Source

fn set_tai(&self, tai_offset: i32) -> Result<(), Self::Error>

Set the offset between TAI and UTC.

Source

fn get_tai(&self) -> Result<i32, Self::Error>

Get the offset between TAI and UTC.

Source

fn error_estimate_update( &self, estimated_error: Duration, maximum_error: Duration, ) -> Result<(), Self::Error>

Provide the system with the current best estimates for the statistical error of the clock, and the maximum deviation due to frequency error and distance to the root clock.

Implementors§