embassy-ptp-driver

Crates

git

Versions

default

Flavors

Skip to main content

Clock

Trait Clock 

Source
pub trait Clock {
    type Error: Error;

    // Required methods
    fn now(&self) -> Timestamp;
    fn step(&mut self, offset_nanos: i64) -> Result<Timestamp, Self::Error>;
    fn set_frequency(
        &mut self,
        adjustment: ScaledPpm,
    ) -> Result<Timestamp, Self::Error>;
}
Expand description

A readable and adjustable PTP hardware clock.

The clock must be the same time domain that produces packet timestamps. Frequency adjustments are absolute relative to the nominal frequency, rather than cumulative.

Required Associated Types§

Source

type Error: Error

Error returned when adjusting the clock.

Required Methods§

Source

fn now(&self) -> Timestamp

Read the current clock time.

Source

fn step(&mut self, offset_nanos: i64) -> Result<Timestamp, Self::Error>

Step the clock and return a timestamp sampled near the change.

A positive offset moves the clock forward. Steps use whole nanoseconds even when timestamp observations have subnanosecond resolution: stepping is a coarse correction, while frequency adjustment preserves fine steering.

Source

fn set_frequency( &mut self, adjustment: ScaledPpm, ) -> Result<Timestamp, Self::Error>

Set the absolute frequency adjustment and return a timestamp sampled near the change.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: ?Sized + Clock> Clock for &mut T

Source§

type Error = <T as Clock>::Error

Source§

fn now(&self) -> Timestamp

Source§

fn step(&mut self, offset_nanos: i64) -> Result<Timestamp, Self::Error>

Source§

fn set_frequency( &mut self, adjustment: ScaledPpm, ) -> Result<Timestamp, Self::Error>

Implementors§