Trait statime::Clock

source ·
pub trait Clock {
    type Error: Debug;

    // Required methods
    fn now(&self) -> Time;
    fn step_clock(&mut self, offset: Duration) -> Result<Time, Self::Error>;
    fn set_frequency(&mut self, ppm: f64) -> Result<Time, Self::Error>;
    fn set_properties(
        &mut self,
        time_properties_ds: &TimePropertiesDS,
    ) -> Result<(), Self::Error>;
}
Expand description

Clock manipulation and querying interface

The clock trait is the primary way the PTP stack interfaces with the system’s clock. It’s implementation should be provided by the user of the Statime crate, and should provide information on and ways to manipulate the system’s clock. An implementation of this trait for linux is provided in the statime-linux crate.

Note that the clock implementation is responsible for handling leap seconds. On most operating systems, this will be provided for by the OS, but on some platforms this may require extra logic.

Required Associated Types§

source

type Error: Debug

Type of the error the methods of this Clock may return

Required Methods§

source

fn now(&self) -> Time

Get the current time of the clock

source

fn step_clock(&mut self, offset: Duration) -> Result<Time, Self::Error>

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

The applied correction should be as close as possible to the requested correction. The reported time of the change should be as close as possible to the time the change was applied

source

fn set_frequency(&mut self, ppm: f64) -> Result<Time, Self::Error>

Set the frequency of the clock, returning the time at which the change was applied. The value is in ppm difference from the clocks base frequency.

The applied correction should be as close as possible to the requested correction. The reported time of the change should be as close as possible to the time the change was applied

source

fn set_properties( &mut self, time_properties_ds: &TimePropertiesDS, ) -> Result<(), Self::Error>

Adjust the timescale properties of the clock, including things like the leap indicator, to the extend supported by the system.

Implementations on Foreign Types§

source§

impl<T: Clock + ?Sized> Clock for Box<T>

§

type Error = <T as Clock>::Error

source§

fn now(&self) -> Time

source§

fn step_clock(&mut self, offset: Duration) -> Result<Time, Self::Error>

source§

fn set_frequency(&mut self, ppm: f64) -> Result<Time, Self::Error>

source§

fn set_properties( &mut self, time_properties_ds: &TimePropertiesDS, ) -> Result<(), Self::Error>

Implementors§

source§

impl<C: Clock> Clock for OverlayClock<C>

§

type Error = <C as Clock>::Error

source§

impl<C: Clock> Clock for SharedClock<C>

§

type Error = <C as Clock>::Error