Skip to main content

PersistentFSM

Struct PersistentFSM 

Source
pub struct PersistentFSM<S, D, C, E, Err>
where S: Clone + Send + 'static, D: Send + 'static, C: Send + 'static, E: Clone + Send + 'static, Err: Error + Send + 'static,
{ /* private fields */ }

Implementations§

Source§

impl<S, D, C, E, Err> PersistentFSM<S, D, C, E, Err>
where S: Clone + PartialEq + Debug + Send + 'static, D: Send + 'static, C: Send + 'static, E: Clone + Send + 'static, Err: Error + Send + 'static,

Source

pub fn new(persistence_id: impl Into<String>) -> Self

Source

pub fn with_initial(self, s: S, d: D) -> Self

Source

pub fn on_command<F>(self, f: F) -> Self
where F: FnMut(&S, &D, C) -> Result<Vec<E>, Err> + Send + 'static,

Source

pub fn on_event<F>(self, f: F) -> Self
where F: FnMut(&mut S, &mut D, &E) + Send + 'static,

Source

pub fn with_codec<EncF, DecF>(self, encode: EncF, decode: DecF) -> Self
where EncF: Fn(&E) -> Result<Vec<u8>, String> + Send + Sync + 'static, DecF: Fn(&[u8]) -> Result<E, String> + Send + Sync + 'static,

Source

pub fn state(&self) -> Option<&S>

Source

pub fn data(&self) -> Option<&D>

Source

pub fn transitions(&self) -> &[(S, S)]

History of state transitions seen since boot. Useful for tests.

Source

pub async fn recover<J: Journal>( &mut self, journal: Arc<J>, permitter: &RecoveryPermitter, ) -> Result<u64, EventsourcedError<Err>>

Source

pub async fn handle<J: Journal>( &mut self, journal: Arc<J>, cmd: C, ) -> Result<(), EventsourcedError<Err>>

Auto Trait Implementations§

§

impl<S, D, C, E, Err> Freeze for PersistentFSM<S, D, C, E, Err>
where S: Freeze, D: Freeze,

§

impl<S, D, C, E, Err> !RefUnwindSafe for PersistentFSM<S, D, C, E, Err>

§

impl<S, D, C, E, Err> Send for PersistentFSM<S, D, C, E, Err>

§

impl<S, D, C, E, Err> !Sync for PersistentFSM<S, D, C, E, Err>

§

impl<S, D, C, E, Err> Unpin for PersistentFSM<S, D, C, E, Err>
where S: Unpin, D: Unpin,

§

impl<S, D, C, E, Err> UnsafeUnpin for PersistentFSM<S, D, C, E, Err>
where S: UnsafeUnpin, D: UnsafeUnpin,

§

impl<S, D, C, E, Err> !UnwindSafe for PersistentFSM<S, D, C, E, Err>

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 = 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.