Skip to main content

Payload

Derive Macro Payload 

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

Derive macro that implements [ringdb::Payload] for a struct.

The storage strategy is selected with the #[payload(storage = "...")] attribute:

ValueStrategyRequirement
"serde" (default)bincode serialization, variable-size payloadsT: Serialize + DeserializeOwned
"pod"raw bytes, zero-copy &T fetchT: bytemuck::Pod

ยงExamples

โ“˜
use serde::{Serialize, Deserialize};
use ringdb::Payload;

// Serde storage (default) โ€” supports any serializable type
#[derive(Serialize, Deserialize, Payload)]
struct GeoRecord { lat: f64, lon: f64, label: String }

// Pod storage โ€” zero-copy &T fetch, requires fixed-size plain-old-data
use bytemuck::{Pod, Zeroable};
#[derive(Copy, Clone, Pod, Zeroable, Payload)]
#[repr(C)]
#[payload(storage = "pod")]
struct GeoPoint { lat: f32, lon: f32, altitude: f32 }