pub trait TypedEvent{
// Provided method
fn into_event(self) -> Event { ... }
}
Expand description
A marker trait for types that can be converted to and from Event
s.
This trait doesn’t make any assumptions about how the conversion is
performed, or how the type’s data is encoded in event attributes. Instead,
it just declares the conversion methods used to serialize the type to an
Event
and to deserialize it from an Event
, allowing downstream users
to declare a single source of truth about how event data is structured.
§Contract
If T: TypedEvent
, then:
T::try_from(e) == Ok(t)
for allt: T, e: Event
whereEvent::from(t).eq_ignoring_index(e) == true
.Event::from(T::try_from(e).unwrap()).eq_ignoring_index(e) == true
for alle: Event
whereT::try_from(e)
returnsOk(_)
.
In other words, the conversion methods should round-trip on the attributes, but are not required to preserve the (nondeterministic) index information.
Provided Methods§
Sourcefn into_event(self) -> Event
fn into_event(self) -> Event
Convenience wrapper around Into::into
that doesn’t require type inference.
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.