Struct libocc::Segment[][src]

pub struct Segment<T> where
    T: Clone + PartialEq
{ /* fields omitted */ }

A segment is a part of an event log.

It’s a list of events followed by a projection, called a “snapshot”. Creating a new segment will make the former segments snapshot immutable, and a new (mutable) segment is created.

Snapshots allow for faster history traversal, as not the entire event log needs to be replayed in order to project an earlier state, unlike a single-segment event log.

Implementations

impl<T> Segment<T> where
    T: Clone + PartialEq
[src]

pub fn new() -> Segment<T>[src]

Creates a new segment

The new segment will have a timestamp of the current time, and won’t have any prior history associated with it.

pub fn from_projection(projection: Vec<T>, events: Vec<Event<T>>) -> Segment<T>[src]

Creates a new segment from a given projection and event log at the current time

pub fn get_time(&self) -> &Timestamp[src]

Returns a shared reference to the timestamp of this segment

pub fn get_projection(&self) -> &Vec<T>[src]

Returns the current projection

pub fn project_at_onto(
    &self,
    timestamp: &Timestamp,
    snapshot: Vec<T>
) -> Option<Vec<T>>
[src]

Projects the segments events predating a specified timestamp onto a given snapshot

pub fn push(&mut self, event: Event<T>) -> Result<()>[src]

Applies and appends an event to the segments snapshot and log, respectively (checked)

pub fn prepend(&mut self, other: Self) -> Result<()>[src]

Merges two consecutive segments by prepending the other before this one (checked)

pub fn prepend_unchecked(&mut self, other: Self)[src]

Merges two consecutive segments by prepending the other before this one (unchecked)

Trait Implementations

impl<T: Clone> Clone for Segment<T> where
    T: Clone + PartialEq
[src]

impl<T: Debug> Debug for Segment<T> where
    T: Clone + PartialEq
[src]

impl<'de, T> Deserialize<'de> for Segment<T> where
    T: Clone + PartialEq,
    T: Deserialize<'de>, 
[src]

impl<T> Serialize for Segment<T> where
    T: Clone + PartialEq,
    T: Serialize
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Segment<T> where
    T: RefUnwindSafe

impl<T> Send for Segment<T> where
    T: Send

impl<T> Sync for Segment<T> where
    T: Sync

impl<T> Unpin for Segment<T> where
    T: Unpin

impl<T> UnwindSafe for Segment<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.