Skip to main content

TimeHistory

Struct TimeHistory 

Source
pub struct TimeHistory<T> { /* private fields */ }
Expand description

Replays a set of times in ascending order, maintaining the meet of the times not yet replayed and a deduplicated buffer of replayed times advanced by that meet. A cheaper ValueHistory for callers that need time structure only (no values, no cancellation).

Implementations§

Source§

impl<T: Lattice + Clone + Ord> TimeHistory<T>

Source

pub fn new() -> Self

An empty history, to be loaded.

Source

pub fn load(&mut self, times: impl Iterator<Item = T>, advance_by: Option<&T>)

Load times, advancing each by advance_by if supplied, and organize the replay (sort + suffix meets).

Source

pub fn time(&self) -> Option<&T>

The next (least) un-replayed time.

Source

pub fn meet(&self) -> Option<&T>

The meet of all un-replayed times.

Source

pub fn step_while_time_is(&mut self, time: &T) -> bool

Step times while the next equals time; true iff any did.

Source

pub fn advance_buffer_by(&mut self, meet: &T)

Advance buffered times by meet and deduplicate — the collapse that keeps replay linear.

Source

pub fn buffer(&self) -> &[T]

The buffered (stepped-in, advanced) times.

Trait Implementations§

Source§

impl<T> Default for TimeHistory<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TimeHistory<T>

§

impl<T> RefUnwindSafe for TimeHistory<T>
where T: RefUnwindSafe,

§

impl<T> Send for TimeHistory<T>
where T: Send,

§

impl<T> Sync for TimeHistory<T>
where T: Sync,

§

impl<T> Unpin for TimeHistory<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TimeHistory<T>

§

impl<T> UnwindSafe for TimeHistory<T>
where T: UnwindSafe,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'a, S, T> Semigroup<&'a S> for T
where T: Semigroup<S>,

Source§

fn plus_equals(&mut self, rhs: &&'a S)

The method of std::ops::AddAssign, for types that do not implement AddAssign.
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.