Skip to main content

ManualWallClock

Struct ManualWallClock 

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

A wall clock projected from a shared ManualMonotonicClock.

Advancing the monotonic clock advances this wall clock by the same duration. Calling reanchor() changes only the wall-time mapping and never changes the underlying monotonic clock.

Implementations§

Source§

impl ManualWallClock

Source

pub fn from_clock( wall_time: SystemTime, clock: Arc<ManualMonotonicClock>, ) -> Self

Creates a wall clock whose current reading is wall_time.

Future readings advance according to the explicitly shared clock.

§Parameters
  • wall_time - Wall-clock value assigned to the current manual instant.
  • clock - Shared manual monotonic timeline driving future readings.
§Returns

A wall clock anchored to the supplied wall and monotonic times.

Source

pub fn reanchor(&self, wall_time: SystemTime)

Reassigns the current monotonic instant to wall_time.

This operation may move wall time forward or backward. It does not advance the monotonic clock and does not wake monotonic sleepers. The anchor mutex remains held while the monotonic clock is sampled, so concurrent calls to now() observe either the old or the new mapping without combining both snapshots.

§Parameters
  • wall_time - Replacement wall time for the current monotonic instant.

Trait Implementations§

Source§

impl Debug for ManualWallClock

Source§

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

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

impl WallClock for ManualWallClock

Source§

fn now(&self) -> SystemTime

Returns wall time derived from the anchor and current monotonic time.

§Returns

The anchored wall time plus elapsed manual monotonic time.

§Panics

Panics if the manually advanced duration cannot be represented by SystemTime. Normal application and test durations are representable.

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