pub struct ClockSyncer { /* private fields */ }Expand description
Stores the state of the source PTP clock (i.e., an open file descriptor to it),
and provides ClockSyncer::sync to set on-demand the system-wide real-time
(i.e., wall-clock time) clock to the time of that source PTP clock.
Implementations§
Source§impl ClockSyncer
impl ClockSyncer
Sourcepub fn with_ptp_clock(dev_ptp_path: impl AsRef<Path>) -> Result<Self, Error>
pub fn with_ptp_clock(dev_ptp_path: impl AsRef<Path>) -> Result<Self, Error>
Create a new ClockSyncer, assuming the provided dev_ptp_path is the path to
the device node (typically under /dev/) that refers to the source PTP clock.
§Errors
- On failure to
open(2)the provided source PTP clock device node.
§Notes
It is up to the caller to provide a path to a device node that refers to a valid
instance of a PTP clock. This is not checked upon ClockSyncer initialization,
and failure to provide so will be manifested through Error::Clock errors in
subsequent ClockSyncer::sync calls.
The auxiliary function verify_ptp_dev attempts to verify whether a path
refers to a device node that corresponds to a PTP clock device.
Use ClockSyncer::with_kvm_clock (which calls find_ptp_kvm) to attempt to
automatically find a device node of KVM’s paravirtualized PTP clock before
constructing the ClockSyncer.
Sourcepub fn with_kvm_clock() -> Result<Self, Error>
pub fn with_kvm_clock() -> Result<Self, Error>
Create a new ClockSyncer, by searching for the KVM PTP clock to be used as the source.
§Errors
- On failure while looking for the KVM PTP clock via
find_ptp_kvm. - On failure to
open(2)the KVM PTP clock device node viawith_ptp_clock.