#d-bus #d-bus #ipc #g-variant

macro zvariant_derive

D-Bus & GVariant encoding & decoding

17 stable releases

new 3.2.1 May 13, 2022
3.1.2 Jan 27, 2022
3.0.0 Dec 19, 2021
2.10.0 Nov 21, 2021
2.0.0 May 22, 2020

#131 in Encoding

Download history 24141/week @ 2022-01-25 22239/week @ 2022-02-01 27161/week @ 2022-02-08 24561/week @ 2022-02-15 25533/week @ 2022-02-22 31994/week @ 2022-03-01 24581/week @ 2022-03-08 26727/week @ 2022-03-15 28547/week @ 2022-03-22 28899/week @ 2022-03-29 29304/week @ 2022-04-05 23975/week @ 2022-04-12 26998/week @ 2022-04-19 29240/week @ 2022-04-26 26926/week @ 2022-05-03 20613/week @ 2022-05-10

107,508 downloads per month
Used in 87 crates (8 directly)

MIT license

44KB
787 lines

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::{EncodingContext, from_slice, to_bytes, Type};
use serde::{Deserialize, Serialize};
use byteorder::LE;

#[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 = EncodingContext::<LE>::new_dbus(0);
let encoded = to_bytes(ctxt, &s).unwrap();
let decoded: Struct = from_slice(&encoded, ctxt).unwrap();
assert_eq!(decoded, s);

Dependencies

~0.6–1.2MB
~27K SLoC