47 stable releases (3 major)

new 5.2.0 Jan 10, 2025
5.1.0 Nov 2, 2024
5.0.1 Oct 21, 2024
4.2.0 Jul 19, 2024
2.0.0 May 22, 2020

#1990 in Encoding

Download history 169393/week @ 2024-09-22 166864/week @ 2024-09-29 173018/week @ 2024-10-06 174147/week @ 2024-10-13 177031/week @ 2024-10-20 179595/week @ 2024-10-27 195237/week @ 2024-11-03 174291/week @ 2024-11-10 194254/week @ 2024-11-17 182157/week @ 2024-11-24 211396/week @ 2024-12-01 216013/week @ 2024-12-08 210768/week @ 2024-12-15 119963/week @ 2024-12-22 151160/week @ 2024-12-29 212651/week @ 2025-01-05

714,498 downloads per month
Used in 550 crates (7 directly)

MIT license

105KB
2K 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.2–3MB
~60K SLoC