36 stable releases

new 4.0.1 Feb 23, 2024
3.15.1 Feb 23, 2024
3.15.0 Jun 28, 2023
3.12.0 Mar 7, 2023
2.0.0 May 22, 2020

#1975 in Encoding

Download history 105173/week @ 2023-11-03 118900/week @ 2023-11-10 118397/week @ 2023-11-17 106672/week @ 2023-11-24 104354/week @ 2023-12-01 108233/week @ 2023-12-08 95444/week @ 2023-12-15 60222/week @ 2023-12-22 82620/week @ 2023-12-29 99804/week @ 2024-01-05 105770/week @ 2024-01-12 153961/week @ 2024-01-19 164914/week @ 2024-01-26 110395/week @ 2024-02-02 121709/week @ 2024-02-09 94735/week @ 2024-02-16

515,127 downloads per month
Used in 370 crates (5 directly)

MIT license

68KB
1K 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.5MB
~56K SLoC