UnixClock

Struct UnixClock 

Source
pub struct UnixClock { /* private fields */ }
Expand description

A Unix OS clock

Implementations§

Source§

impl UnixClock

Source

pub const CLOCK_REALTIME: Self

The standard realtime clock on unix systems.

use clock_steering::{Clock, unix::UnixClock};

fn main() -> std::io::Result<()> {
    let clock = UnixClock::CLOCK_REALTIME;
    let now = clock.now()?;

    println!("{now:?}");

    Ok(())
}
Source

pub const CLOCK_TAI: Self

TAI time on linux systems.

use clock_steering::{Clock, unix::UnixClock};

fn main() -> std::io::Result<()> {
    let clock = UnixClock::CLOCK_TAI;
    let now = clock.now()?;

    println!("{now:?}");

    Ok(())
}
Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open a clock device.

use clock_steering::{Clock, unix::UnixClock};

fn main() -> std::io::Result<()> {
    let clock = UnixClock::open("/dev/ptp0")?;
    let now = clock.now()?;

    println!("{now:?}");

    Ok(())
}
Source

pub fn system_offset(&self) -> Result<(Timestamp, Timestamp, Timestamp), Error>

Determine offset between file clock and TAI clock (if any) Returns two system timestamps sandwhiching a timestamp from the hardware clock.

Trait Implementations§

Source§

impl Clock for UnixClock

Source§

type Error = Error

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. Read more
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 set_frequency(&self, frequency: f64) -> Result<Timestamp, Self::Error>

Change the frequency of the clock. Returns the time at which the change was applied. Read more
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 error_estimate_update( &self, est_error: Duration, max_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.
Source§

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

Disable all standard NTP kernel clock discipline. It is all your responsibility now. Read more
Source§

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

Set the offset between TAI and UTC.
Source§

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

Get the offset between TAI and UTC.
Source§

impl Clone for UnixClock

Source§

fn clone(&self) -> UnixClock

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnixClock

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for UnixClock

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.