pub struct ReceivePersistent<S, E, Err>{ /* private fields */ }Expand description
Closure-style persistent actor.
Implementations§
Source§impl<S, E, Err> ReceivePersistent<S, E, Err>
impl<S, E, Err> ReceivePersistent<S, E, Err>
pub fn new(persistence_id: impl Into<String>) -> Self
Sourcepub fn on_command<F>(self, f: F) -> Self
pub fn on_command<F>(self, f: F) -> Self
Register the command handler. The closure receives the current
state + the incoming command (the command type matches the
event type for this minimal helper; richer command-vs-event
shapes use Eventsourced directly).
Sourcepub fn with_codec<EncF, DecF>(self, encode: EncF, decode: DecF) -> Self
pub fn with_codec<EncF, DecF>(self, encode: EncF, decode: DecF) -> Self
Register the codec used to round-trip events through the journal.
pub fn state(&self) -> &S
pub fn persistence_id(&self) -> &str
Sourcepub async fn recover<J: Journal>(
&mut self,
journal: Arc<J>,
permitter: &RecoveryPermitter,
) -> Result<u64, EventsourcedError<Err>>
pub async fn recover<J: Journal>( &mut self, journal: Arc<J>, permitter: &RecoveryPermitter, ) -> Result<u64, EventsourcedError<Err>>
Replay the journal under permitter and apply each event.
Auto Trait Implementations§
impl<S, E, Err> Freeze for ReceivePersistent<S, E, Err>where
S: Freeze,
impl<S, E, Err> !RefUnwindSafe for ReceivePersistent<S, E, Err>
impl<S, E, Err> Send for ReceivePersistent<S, E, Err>
impl<S, E, Err> !Sync for ReceivePersistent<S, E, Err>
impl<S, E, Err> Unpin for ReceivePersistent<S, E, Err>where
S: Unpin,
impl<S, E, Err> UnsafeUnpin for ReceivePersistent<S, E, Err>where
S: UnsafeUnpin,
impl<S, E, Err> !UnwindSafe for ReceivePersistent<S, E, Err>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more