pub trait ProjectionEvent: Sized {
const EVENT_KINDS: &'static [&'static str];
// Required method
fn from_stored<C: Codec>(
kind: &str,
data: &[u8],
codec: &C,
) -> Result<Self, EventDecodeError<C::Error>>;
}Expand description
Trait for event sum types that can deserialize themselves from stored events.
Implemented by event enums to deserialize 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§
Sourceconst EVENT_KINDS: &'static [&'static str]
const EVENT_KINDS: &'static [&'static str]
The list of event kinds this sum type can deserialize.
This data is generated automatically when using the derive macros.
Required Methods§
Sourcefn from_stored<C: Codec>(
kind: &str,
data: &[u8],
codec: &C,
) -> Result<Self, EventDecodeError<C::Error>>
fn from_stored<C: Codec>( kind: &str, data: &[u8], codec: &C, ) -> Result<Self, EventDecodeError<C::Error>>
Deserialize an event from stored representation.
§Errors
Returns EventDecodeError::UnknownKind if the event kind is not
recognized, or EventDecodeError::Codec if deserialization 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.