#[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:
| Value | Strategy | Requirement |
|---|---|---|
"serde" (default) | bincode serialization, variable-size payloads | T: Serialize + DeserializeOwned |
"pod" | raw bytes, zero-copy &T fetch | T: 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 }