Skip to main content

SerializePayload

Derive Macro SerializePayload 

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

Derives the SerializePayload trait.

Serializes the struct’s fields as sequential elements of a JSON array. Used for the emit (outbound) direction. Pair with EventType or AckType.

§Field attributes

  • #[sioc(flatten)]: serialize each element of this collection field as a separate array element. Recommended on the last field.

§Example

// ignore: sioc-macros cannot dev-depend on sioc (circular); see sioc crate for runnable examples.
use sioc::prelude::*;

#[derive(EventType, SerializePayload)]
struct Move {
    x: i32,
    y: i32,
    #[sioc(flatten)]
    tags: Vec<String>,
}