pub struct PhcClock { /* private fields */ }Expand description
PTP Hardware Clock (PHC) accessed via /dev/ptpN.
This provides direct access to the NIC’s hardware clock through the Linux PTP subsystem. The PHC can be read with nanosecond precision and disciplined independently of the system clock.
The internal Mutex ensures that read-modify-write operations like step()
are atomic with respect to concurrent callers.
Implementations§
Source§impl PhcClock
impl PhcClock
Sourcepub fn open(device: &str) -> Result<Self, ClockError>
pub fn open(device: &str) -> Result<Self, ClockError>
Open a PTP hardware clock device.
device should be a path like /dev/ptp0. The device must exist and be
readable by the current process.
Sourcepub fn read_time(&self) -> Result<PtpTimestamp, ClockError>
pub fn read_time(&self) -> Result<PtpTimestamp, ClockError>
Read the PHC time as a PtpTimestamp.
Uses clock_gettime with the dynamic clockid derived from the PHC file
descriptor.
Sourcepub fn device_path(&self) -> &str
pub fn device_path(&self) -> &str
Get the device path this clock was opened from.
Trait Implementations§
Source§impl Clock for PhcClock
impl Clock for PhcClock
Source§fn now(&self) -> Result<NtpTimestamp, ClockError>
fn now(&self) -> Result<NtpTimestamp, ClockError>
Read current time from this clock.
Source§fn step(&self, offset: NtpDuration) -> Result<(), ClockError>
fn step(&self, offset: NtpDuration) -> Result<(), ClockError>
Apply a step adjustment (instant offset). Requires privilege.
Source§fn adjust_frequency(&self, ppm: f64) -> Result<(), ClockError>
fn adjust_frequency(&self, ppm: f64) -> Result<(), ClockError>
Apply a slew adjustment (frequency change in PPM). Requires privilege.
Source§fn frequency_offset(&self) -> Result<f64, ClockError>
fn frequency_offset(&self) -> Result<f64, ClockError>
Read current frequency offset in PPM.
Source§fn resolution(&self) -> NtpDuration
fn resolution(&self) -> NtpDuration
Get clock resolution as a duration.
Source§fn max_frequency_adjustment(&self) -> f64
fn max_frequency_adjustment(&self) -> f64
Maximum allowed frequency adjustment in PPM.
Source§fn is_adjustable(&self) -> bool
fn is_adjustable(&self) -> bool
Whether this clock supports discipline (has CAP_SYS_TIME or equivalent).
Auto Trait Implementations§
impl !Freeze for PhcClock
impl RefUnwindSafe for PhcClock
impl Send for PhcClock
impl Sync for PhcClock
impl Unpin for PhcClock
impl UnsafeUnpin for PhcClock
impl UnwindSafe for PhcClock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more