serde-ubj
Universal Binary JSON data format for Rust with Serde (both std and no_std environments).
This project does:
- implement the
serde::Serializertrait for most of the Serde data model types, - support optimized
serialize_bytes(that you can enable via theserde_bytescrate), - support both
std(standard) andno_stdenvironments (by replying upon theembedded-ioproject), - pass enough unit tests covering at least 85% of its code base.
tl;dr
For the impatient.
serialization
With any Rust std writer of your choice (i.e., output console, memory buffer, file on disk, network socket, etc.), serialize any value for which you have either derived
or provided a serde::Serialize implementation to Universal Binary JSON in a few instructions:
use ;
deserialization
Whit any Rust std buffered reader of your choice (i.e., input console, memory buffer, file on disk, network socket, etc.), deserialize any value for which you have either derived or provided serde::Deserialize implementation from Universal Binary JSON in a few instructions:
use
exceptions
This implementation does not support the following Serde types:
-
serialization
- Serde byte array
- Serde numeric
u64values greater than Rusti64::MAX - Serde numeric
i128,u128 - Serde
stringhaving length greater than Rusti64::MAX, - UBJ optimizations
-
deserialization
- all exceptions above, and
- Serde
u16,u32,u64 - Serde
&str
limitations
This implementation is made with the following limitations:
-
strings
their length must be not greater thani64::MAX -
maps
keys must beStrings
no_std
This implementation can be adopted in no_std environments, as long as you disable the default features and, at the same time, enable the embedded-io feature, as per following Cargo.toml example:
[]
= "my_no_std_project"
= "0.1.0"
= "2024"
[]
= { = "0.2.0", = false, = ["embedded-io"] }
= { = "latest" }
book
Coming soon.