43 个稳定版本
4.2.0 | 2024年7月19日 |
---|---|
4.1.1 | 2024年5月20日 |
4.0.2 | 2024年2月25日 |
3.15.2 | 2024年2月25日 |
2.0.0 | 2020年5月22日 |
#16 in #d-bus
706,344 每月下载量
在 440 个crate中使用 (5 直接使用)
68KB
1K SLoC
zvariant_derive
此crate为zvariant
提供了 derive 宏辅助工具。为了方便,zvariant
crate 会重新导出这些宏,因此您无需直接使用此crate。
状态:稳定。
示例代码
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);
依赖
~1.3–2MB
~40K SLoC