#[derive(GraphValue)]
{
// Attributes available to this derive:
#[graph]
}
Expand description
Derive macro for converting between Rust types and Value.
§Structs
Structs are converted to Value::Record with field names as keys.
ⓘ
#[derive(GraphValue)]
struct Person {
name: String,
age: i64,
}§Enums
Enums are converted to Value::Variant with the variant index as tag.
ⓘ
#[derive(GraphValue)]
enum Shape {
Circle(f64), // tag 0, payload = radius
Rectangle(f64, f64), // tag 1, payload = tuple(width, height)
Point, // tag 2, no payload
}§Attributes
#[graph(crate = "path")]- Specify the crate path (default:packr_abi)#[graph(rename = "name")]- Use a different name for field/variant#[graph(tag = N)]- Use explicit tag number for variant#[graph(forward_compatible)]- Tolerant decode for schema evolution on a STRUCT: a missing field defaults and an extra field is ignored, so appending a field is decode-safe both ways (old build reads new data; new build reads old data — no rollback data loss, no hand-written pad-missing migration). Default (absent) is a strict field-count decode. Named structs match fields by name (add/remove/reorder tolerated); tuple structs are positional, so only APPENDING a trailing field is safe. Encode is unchanged (wire-compatible).