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§
Sourcefn resolution(&self) -> Result<Timestamp, Self::Error>
fn resolution(&self) -> Result<Timestamp, Self::Error>
Get the clock’s resolution.
The output Timestamp will be all zeros when the resolution is
unavailable.
Sourcefn set_frequency(&self, frequency: f64) -> Result<Timestamp, Self::Error>
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.
Sourcefn get_frequency(&self) -> Result<f64, Self::Error>
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.
Sourcefn step_clock(&self, offset: TimeOffset) -> Result<Timestamp, Self::Error>
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.
Sourcefn set_leap_seconds(
&self,
leap_status: LeapIndicator,
) -> Result<(), Self::Error>
fn set_leap_seconds( &self, leap_status: LeapIndicator, ) -> Result<(), Self::Error>
Change the indicators for upcoming leap seconds.
Sourcefn disable_kernel_ntp_algorithm(&self) -> Result<(), Self::Error>
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:
libc::STA_PLL: kernel phase-locked looplibc::STA_FLL: kernel frequency-locked looplibc::STA_PPSTIME: pulse-per-second timelibc::STA_PPSFREQ: pulse-per-second frequency discipline