Struct eventsourced::EntityRef
source · pub struct EntityRef<E>where
E: EventSourced,{ /* private fields */ }Expand description
A handle for a spawned EventSourced entity which can be used to invoke its command handler.
Implementations§
source§impl<E> EntityRef<E>where
E: EventSourced,
impl<E> EntityRef<E>where
E: EventSourced,
sourcepub async fn handle_cmd(
&self,
cmd: E::Cmd
) -> Result<Result<(), E::Error>, EntityRefError>
pub async fn handle_cmd(
&self,
cmd: E::Cmd
) -> Result<Result<(), E::Error>, EntityRefError>
Invoke the command handler of the entity.
The returned (outer) Result signals, whether the command could be sent to the entity and
the command handler result could be received, i.e. an Err signals a technical failure.
The (outer) Ok variant contains another (inner) Result, which signals whether the
command was valid or rejected. If it was valid, the persisted event is returned, else the
rejection error.