Event

Derive Macro Event 

Source
#[derive(Event)]
{
    // Attributes available to this derive:
    #[ruma_event]
}
Expand description

Generates trait implementations for Matrix event types.

This macro parses the name of the type on which it is applied to decide what to do, which means that it only works on a fixed list of types. It also requires the type to be a struct with named fields, with one of these fields named content.

This macro implements at least Deserialize for the type on which it is applied.

If the type is an OriginalSync or RedactedSync event, this implements conversion helpers to the non-sync version of the event type. For example if the event type is OriginalSyncMessageLikeEvent, this will generate From<OriginalMessageLikeEvent> for OriginalSyncMessageLikeEvent and OriginalSyncMessageLikeEvent::into_full_event().

If the type is a non-stripped timeline event, i.e. a struct with an event_id field, this implements PartialEq, Eq, PartialOrd and Ord by comparing the event_id fields.

§Field attributes

The following settings can be used on the fields of the struct, with the #[ruma_event(_)] attribute.

§default

If the field is missing, its Default implementation is used.

§default_on_error

If an error occurs during deserialization of the value of this field, its Default implementation is used. The error is logged with the tracing crate at the debug level, which means that it must be a dependency of the crate where the macro is used.

§rename = "serialized_name"

Use a different name when the field is serialized. The name is used both during serialization and deserialization.

§alias = "alt_name"

Allow a different name for the field during deserialization. This can be used several times for different aliases.

You can use cargo doc to find out more details, its --document-private-items flag also lets you generate documentation for binaries or private parts of a library.