Closed zeenix closed 1 year ago
In GitLab by @hojjatabdollahi on Aug 12, 2022, 21:45
The bincode can serialize structs implementing serde::Serialize but not zvariant::Serialize. See this example:
serde::Serialize
zvariant::Serialize
use serde::Serialize; use zbus::zvariant::SerializeDict; #[derive(Serialize)] struct S1 { f1: u32, } #[derive(SerializeDict)] struct S2 { f1: u32, } fn main() { let s1 = S1 { f1: 3 }; let s2 = S2 { f1: 3 }; bincode::serialize(&s1).unwrap(); // <- Works fine bincode::serialize(&s2).unwrap(); // <- Error }
This fails with: thread 'main' panicked at 'called Result::unwrap() on an Err value: SequenceMustHaveLength', src/main.rs:17:29
thread 'main' panicked at 'called Result::unwrap() on an Err value: SequenceMustHaveLength', src/main.rs:17:29
@hojjatabdollahi Thanks for filing this. As I expected, the fix was trivial.
In GitLab by @hojjatabdollahi on Aug 12, 2022, 21:45
The bincode can serialize structs implementing
serde::Serialize
but notzvariant::Serialize
. See this example:This fails with:
thread 'main' panicked at 'called Result::unwrap() on an Err value: SequenceMustHaveLength', src/main.rs:17:29