pub struct U64Calibration { /* private fields */ }Expand description
Integer multiply-shift calibration for WrappingU64Duration.
Converts between raw ticks and nanoseconds using precomputed multiply-shift factors.
Implementations§
Source§impl U64Calibration
impl U64Calibration
Sourcepub fn new(duration: WrappingU64Duration, duration_ns: u64) -> Self
pub fn new(duration: WrappingU64Duration, duration_ns: u64) -> Self
Creates a calibration from a measured duration and its nanosecond equivalent.
Sourcepub fn new_with_reference_clock<C: Clock<Time = WrappingU64Time>, R: Clock>(
clock: &C,
reference_clock: &CalibratedClock<R>,
min_duration: <R::Time as Time>::Duration,
wait: impl FnMut(<R::Time as Time>::Instant),
) -> (Self, ClockSynchronization<R::Time, C::Time>)
pub fn new_with_reference_clock<C: Clock<Time = WrappingU64Time>, R: Clock>( clock: &C, reference_clock: &CalibratedClock<R>, min_duration: <R::Time as Time>::Duration, wait: impl FnMut(<R::Time as Time>::Instant), ) -> (Self, ClockSynchronization<R::Time, C::Time>)
Calibrates clock against reference_clock, calling wait until min_duration elapses.
Returns the calibration and a ClockSynchronization relating the two clocks to each other
wait is invoked with the instant until which it should wait.
Sourcepub fn new_with_std_instant<C: Clock<Time = WrappingU64Time>>(
clock: &C,
min_duration: Duration,
) -> (Self, ClockSynchronization<InstantTime, C::Time>)
pub fn new_with_std_instant<C: Clock<Time = WrappingU64Time>>( clock: &C, min_duration: Duration, ) -> (Self, ClockSynchronization<InstantTime, C::Time>)
Calibrates clock against std::time::Instant, sleeping for at least min_duration.
This is a convenience wrapper around U64Calibration::new_with_reference_clock based on std::time::Instant and std::thread::sleep.
Trait Implementations§
Source§impl Clone for U64Calibration
impl Clone for U64Calibration
Source§fn clone(&self) -> U64Calibration
fn clone(&self) -> U64Calibration
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for U64Calibration
Source§impl Debug for U64Calibration
impl Debug for U64Calibration
Source§impl DurationCalibration<WrappingU64Duration> for U64Calibration
impl DurationCalibration<WrappingU64Duration> for U64Calibration
Source§fn convert_to_ns(&self, d: WrappingU64Duration) -> u64
fn convert_to_ns(&self, d: WrappingU64Duration) -> u64
Converts a duration to nanoseconds, rounding to the nearest nanosecond.
Source§fn convert_from_ns(&self, ns: u64) -> WrappingU64Duration
fn convert_from_ns(&self, ns: u64) -> WrappingU64Duration
Converts a nanosecond value to this clock’s native duration type.
fn to_std(&self, d: D) -> Durationwhere
Self: Sized,
fn convert_from_std(&self, d: Duration) -> Dwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for U64Calibration
impl RefUnwindSafe for U64Calibration
impl Send for U64Calibration
impl Sync for U64Calibration
impl Unpin for U64Calibration
impl UnsafeUnpin for U64Calibration
impl UnwindSafe for U64Calibration
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