Skip to main content

Crate sioc_macros

Crate sioc_macros 

Source
Expand description

§sioc-macros

Derive macros for sioc.

DeriveDescription
EventTypeImplements EventType by providing the event name constant and declaring whether the event uses acknowledgement and binary attachments.
AckTypeImplements AckType by declaring whether the acknowledgement carries binary attachments.
SerializePayloadImplements SerializePayload by encoding struct fields as sequential JSON array elements. All fields must implement serde::Serialize.
DeserializePayloadImplements DeserializePayload by decoding sequential JSON array elements into struct fields. All fields must implement serde::Deserialize.
EventRouterImplements EventRouter and TryFrom<DynEvent> by routing an incoming event to the matching variant by name. Each variant must wrap Event<E> where E implements EventType and DeserializePayload.

§Struct-level attributes

AttributeApplies toEffect
event(name = "str")EventTypeOverrides the event name. By default the struct name is converted to snake_case, so MyEvent becomes "my_event".
event(ack = Type)EventTypeDeclares that this event expects an acknowledgement of type Type. Without this the event has no acknowledgement.
event(binary)EventTypeMarks the event as carrying binary attachments. Without this the event has no binary attachments.
ack(binary)AckTypeMarks the acknowledgement as carrying binary attachments. Without this the ack has no binary attachments.
strictDeserializePayloadRejects payloads that contain more elements than the struct has fields. By default, extra elements are ignored.

§Field-level attributes

AttributeApplies toEffect
flattenSerializePayload, DeserializePayloadEach element of this collection field is serialized as a separate array element, and all remaining array elements are collected into it on the way in. Must be the last field.

§License

MIT OR Apache-2.0.

Derive Macros§

AckType
Derives the AckType trait, providing the binary policy associated type.
DeserializePayload
Derives the DeserializePayload trait.
EventRouter
Derives EventRouter, generating TryFrom<DynEvent> for a dispatcher enum.
EventType
Derives the EventType trait, providing the event name constant and ack/binary policy associated types.
SerializePayload
Derives the SerializePayload trait.