| Crates.io | zvariant_derive |
| lib.rs | zvariant_derive |
| version | 5.9.2 |
| created_at | 2020-05-22 13:09:28.990065+00 |
| updated_at | 2026-01-18 18:35:44.674343+00 |
| description | D-Bus & GVariant encoding & decoding |
| homepage | |
| repository | https://github.com/z-galaxy/zbus/ |
| max_upload_size | |
| id | 244576 |
| size | 71,579 |
This crate provides derive macros helpers for zvariant. The zvariant crate re-exports these
macros for your convenience so you do not need to use this crate directly.
Status: Stable.
use zvariant::{serialized::Context, to_bytes, Type, LE};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Type, PartialEq, Debug)]
struct Struct<'s> {
field1: u16,
field2: i64,
field3: &'s str,
}
assert_eq!(Struct::SIGNATURE, "(qxs)");
let s = Struct {
field1: 42,
field2: i64::max_value(),
field3: "hello",
};
let ctxt = Context::new_dbus(LE, 0);
let encoded = to_bytes(ctxt, &s).unwrap();
let decoded: Struct = encoded.deserialize().unwrap().0;
assert_eq!(decoded, s);