Struct libocc::Segment [−][src]
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<'a, T> Segment<'a, T> where
T: Clone + PartialEq,
[src]
T: Clone + PartialEq,
pub fn new() -> Segment<'a, 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<Cow<'a, T>>,
events: Vec<Event<'a, T>>
) -> Segment<'a, T>
[src]
projection: Vec<Cow<'a, T>>,
events: Vec<Event<'a, T>>
) -> Segment<'a, T>
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<Cow<'a, T>>ⓘ
[src]
Returns the current projection
pub fn project_at_onto(
&self,
timestamp: &Timestamp,
snapshot: Vec<Cow<'a, T>>
) -> Option<Vec<Cow<'a, T>>>
[src]
&self,
timestamp: &Timestamp,
snapshot: Vec<Cow<'a, T>>
) -> Option<Vec<Cow<'a, T>>>
Projects the segments events predating a specified timestamp onto a given snapshot
pub fn push(&mut self, event: Event<'a, 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<'a, T: Clone> Clone for Segment<'a, T> where
T: Clone + PartialEq,
[src]
T: Clone + PartialEq,
impl<'a, T: Debug> Debug for Segment<'a, T> where
T: Clone + PartialEq,
[src]
T: Clone + PartialEq,
impl<'de, 'a, T> Deserialize<'de> for Segment<'a, T> where
T: Clone + PartialEq,
T: Deserialize<'de>,
[src]
T: Clone + PartialEq,
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<'a, T> Serialize for Segment<'a, T> where
T: Clone + PartialEq,
T: Serialize,
[src]
T: Clone + PartialEq,
T: Serialize,
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for Segment<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> Send for Segment<'a, T> where
T: Send + Sync,
T: Send + Sync,
impl<'a, T> Sync for Segment<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for Segment<'a, T> where
T: Unpin,
T: Unpin,
impl<'a, T> UnwindSafe for Segment<'a, T> where
T: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,