CommandEffect

Enum CommandEffect 

Source
pub enum CommandEffect<E, Reply, Error>
where E: EventSourced,
{ EmitAndReply(E::Event, Box<dyn FnOnce(&E) -> Reply + Send + Sync>), Reply(Reply), Reject(Error), }
Expand description

The result of handling a command, either emitting an event and replying or rejecting the command.

Variants§

§

EmitAndReply(E::Event, Box<dyn FnOnce(&E) -> Reply + Send + Sync>)

§

Reply(Reply)

§

Reject(Error)

Implementations§

Source§

impl<E, Reply, Error> CommandEffect<E, Reply, Error>
where E: EventSourced,

Source

pub fn emit_and_reply( event: E::Event, make_reply: impl FnOnce(&E) -> Reply + Send + Sync + 'static, ) -> Self

Emit the given event, persist it, and after applying it to the state, use the given function to create a reply. The new state is passed to the function after applying the event.

Source

pub fn reply(reply: Reply) -> Self

Reply with the given value without emitting any event.

Source

pub fn reject(error: Error) -> Self

Reject this command with the given error.

Source§

impl<E, Error> CommandEffect<E, (), Error>
where E: EventSourced,

Source

pub fn emit(event: E::Event) -> Self

Persist the given event (and don’t give a reply for Commands with Reply = ()).

Auto Trait Implementations§

§

impl<E, Reply, Error> Freeze for CommandEffect<E, Reply, Error>
where <E as EventSourced>::Event: Freeze, Reply: Freeze, Error: Freeze,

§

impl<E, Reply, Error> !RefUnwindSafe for CommandEffect<E, Reply, Error>

§

impl<E, Reply, Error> Send for CommandEffect<E, Reply, Error>
where Reply: Send, Error: Send,

§

impl<E, Reply, Error> Sync for CommandEffect<E, Reply, Error>
where Reply: Sync, Error: Sync,

§

impl<E, Reply, Error> Unpin for CommandEffect<E, Reply, Error>
where <E as EventSourced>::Event: Unpin, Reply: Unpin, Error: Unpin,

§

impl<E, Reply, Error> !UnwindSafe for CommandEffect<E, Reply, Error>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more