PersistedClock

Struct PersistedClock 

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

A Clock implementation, that can be persisted to disk, via the from_path or save_to_file functions.

Implementations§

Source§

impl PersistedClock

Source

pub fn new(path: PathBuf) -> Result<Self, Error>

Create a new PersistedClock. This will override the contents of path. If you want to re-load a previously persisted clock, use PersistedClock::from_path.

§Errors

If the path cannot be opened for writing.

Source

pub fn from_path(path: PathBuf) -> Result<Self, Error>

Loads this clock from a previously persisted clock.

§Errors

If the path cannot be opened for reading and writing.

Source

pub fn save_to_file(&mut self, create: bool) -> Result<(), Error>

Save this clock to disk.

§Note

The file needs to be opened in read-write mode, because we check that the file’s content reflect our clock value.

§Errors

If the IO operations fail.

§Panics

If our time is behind the files stored time.

Trait Implementations§

Source§

impl Clock for PersistedClock

Source§

type IncrementError = Error

The Error returned, when trying to increment this clock.
Source§

type WitnessError = Error

The Error returned, when trying to witness this clock.
Source§

fn time(&self) -> Time

Get the current value of this clock.
Source§

fn increment(&mut self) -> Result<Time, Self::IncrementError>

Return the current value and increment it internally. Read more
Source§

fn witness(&mut self, time: Time) -> Result<(), Self::WitnessError>

Update our clock based on another processes clock’s value, we “witnessed”. Read more
Source§

impl Debug for PersistedClock

Source§

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

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,