-
Notifications
You must be signed in to change notification settings - Fork 43
Description
This issue is for discussing things related to serde support.
Unresolved questions:
Serde data model mismatch
The serde data model states that it supports 14 primitive types. All of them is aligned on 8, 16, 64 or 128 bits. Is it possible to represent the types of this crates (conceptually aligned at other bit positions) with the serde memory model in a way that will be correct for all implemented protocols (including those that will be implemented in the future).
One example of problematic behavior is the u24
type, when serialized with JSON it should print a single number between 0 and 2^24. When serialized with a binary format, should it behave as a u32
(serialize into 4 bytes) or as an [u8; 3]
(serialized into 3 bytes)?
Another problematic example is the following struct:
#[derive(Serialize, Deserialize)]
pub struct {
foo: u7,
bar: u9,
}
How should this struct be serialized for a binary format, as 2 bytes or 3 bytes?
It seems like it's the binary formats that are problematic and text based format (like json) is trivial. If there would be any way to opt out of binary format that would probably be a good idea for the time being.
Stability guarantees
This crate has stability as one of it's main goal, are there any ways we can also support a serde v2 release without breaking this crate?