58 stable releases
Uses new Rust 2024
| new 5.9.2 | Jan 18, 2026 |
|---|---|
| 5.8.0 | Oct 15, 2025 |
| 5.6.0 | Jul 7, 2025 |
| 5.4.0 | Feb 7, 2025 |
| 2.0.0 | May 22, 2020 |
#2662 in Encoding
1,923,816 downloads per month
Used in 900 crates
(8 directly)
120KB
2.5K
SLoC
zvariant_derive
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.
Example code
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);
Dependencies
~2.4–3.5MB
~76K SLoC