Skip to main content

ProjectionEvent

Trait ProjectionEvent 

Source
pub trait ProjectionEvent: Sized {
    const EVENT_KINDS: &'static [&'static str];

    // Required method
    fn from_stored<S: EventStore>(
        stored: &StoredEvent<S::Id, S::Position, S::Data, S::Metadata>,
        store: &S,
    ) -> Result<Self, EventDecodeError<S::Error>>;
}
Expand description

Trait for event sum types that can deserialise themselves from stored events.

Implemented by event enums to deserialise stored events.

Deriving Aggregate includes a ProjectionEvent implementation for the generated sum type. Custom enums can opt in manually using the pattern illustrated below.

Required Associated Constants§

Source

const EVENT_KINDS: &'static [&'static str]

The list of event kinds this sum type can deserialise.

This data is generated automatically when using the derive macros.

Required Methods§

Source

fn from_stored<S: EventStore>( stored: &StoredEvent<S::Id, S::Position, S::Data, S::Metadata>, store: &S, ) -> Result<Self, EventDecodeError<S::Error>>

Deserialise an event from stored representation.

§Errors

Returns EventDecodeError::UnknownKind if the event kind is not recognised, or EventDecodeError::Store if deserialisation fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§