Skip to main content

StreamHistory

Struct StreamHistory 

Source
pub struct StreamHistory<E> { /* private fields */ }
Expand description

English:
Non-empty, complete history in replay order starting at revision 0. Construction checks event count against the final revision, not event contents or identity.

日本語:
リビジョン 0 から始まる再生順の空でない完全な履歴です。 構築時にはイベント数と最終リビジョンを照合し、内容や識別子は検証しません。

§Example / 使用例

use ddd_toolkit_core::{StreamHistory, StreamRevision};
let history = StreamHistory::try_new(vec!["created", "updated"], StreamRevision::new(1))?;
assert_eq!(history.events_after(StreamRevision::new(0)), Some(&["updated"][..]));
assert_eq!(history.events_after(StreamRevision::new(1)), Some(&[][..]));

Implementations§

Source§

impl<E> StreamHistory<E>

Source

pub fn try_new( events: Vec<E>, revision: StreamRevision, ) -> Result<StreamHistory<E>, StreamHistoryError>

English:
Takes ownership of events and checks that revision equals their count minus one. Returns StreamHistoryError::Empty for no events, StreamHistoryError::TooManyEvents if the count cannot fit in u64, or StreamHistoryError::RevisionMismatch for a mismatch.

日本語:
イベントを所有し、revision がイベント数から 1 を引いた値か確認します。 空なら StreamHistoryError::Empty、件数が u64 に収まらなければ StreamHistoryError::TooManyEvents、不一致なら StreamHistoryError::RevisionMismatch を返します。

Source

pub fn events(&self) -> &[E]

English:
Borrows all events in construction order.

日本語:
構築時の順序ですべてのイベントを借用します。

Source

pub fn revision(&self) -> StreamRevision

English:
Returns the final event’s revision.

日本語:
最後のイベントのリビジョンを返します。

Source

pub fn into_events(self) -> Vec<E>

English:
Consumes the history and returns its events without cloning.

日本語:
履歴を消費し、複製せずにイベントを返します。

Source

pub fn events_after(&self, revision: StreamRevision) -> Option<&[E]>

English:
Borrows events strictly after revision; the final revision yields an empty slice. Returns None for a future revision or if the next index cannot fit in usize.

日本語:
revision より後のイベントを借用します。最終リビジョンなら空スライスです。 未来のリビジョンや、次の添字が usize に収まらない場合は None を返します。

Trait Implementations§

Source§

impl<E> Debug for StreamHistory<E>
where E: Debug,

Source§

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

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

impl<E> Eq for StreamHistory<E>
where E: Eq,

Source§

impl<E> PartialEq for StreamHistory<E>
where E: PartialEq,

Source§

fn eq(&self, other: &StreamHistory<E>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<E> StructuralPartialEq for StreamHistory<E>
where E: PartialEq,

Auto Trait Implementations§

§

impl<E> Freeze for StreamHistory<E>
where Vec<E>: Freeze,

§

impl<E> RefUnwindSafe for StreamHistory<E>
where Vec<E>: RefUnwindSafe,

§

impl<E> Send for StreamHistory<E>
where Vec<E>: Send,

§

impl<E> Sync for StreamHistory<E>
where Vec<E>: Sync,

§

impl<E> Unpin for StreamHistory<E>
where Vec<E>: Unpin,

§

impl<E> UnsafeUnpin for StreamHistory<E>
where Vec<E>: UnsafeUnpin,

§

impl<E> UnwindSafe for StreamHistory<E>
where Vec<E>: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.