| Crates.io | serde_ubj |
| lib.rs | serde_ubj |
| version | 0.2.0 |
| created_at | 2025-12-19 21:05:05.035494+00 |
| updated_at | 2026-01-17 17:08:43.828711+00 |
| description | Universal Binary JSON data format for Rust with Serde (both `std` and `no_std` environments). |
| homepage | |
| repository | https://github.com/pangiole/serde-ubj |
| max_upload_size | |
| id | 1995523 |
| size | 136,194 |
Universal Binary JSON data format for Rust with Serde (both std and no_std environments).
This project is in an early stage of development, and not production ready yet.
Use with caution!
This project does:
implement the serde::Serializer trait for most of the Serde data model types,
support optimized serialize_bytes (that you can enable via the serde_bytes crate),
support both std (standard) and no_std environments (by replying upon the embedded-io project),
pass enough unit tests covering at least 85% of its code base.
For the impatient.
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 sdt::{error, io};
fn main() -> Result<(), Box<dyn error::Error>> {
let value = 123_i16;
// let value = ... my model type ...
// With any IO writer, serialize the value
let mut w: io::Write = io::stdout();
serde_ubj::to_writer(&w, &value)?;
}
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 sdt::{error,io}
fn main() -> Result<(), Box<dyn error::Error>> {
// With any IO buffered reader,
let mut r: io::BufRead = ...;
// Deserialize the value of type `T`
let value: T = serde_ubj::from_buf_reader(&mut r)?;
Ok(())
}
This implementation does not support the following Serde types:
serialization
u64 values greater than Rust i64::MAXi128, u128string having length greater than Rust i64::MAX,deserialization
u16, u32, u64&strThis implementation is made with the following limitations:
strings
their length must be not greater than i64::MAX
maps
keys must be Strings
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:
[package]
name = "my_no_std_project"
version = "0.1.0"
edition = "2024"
[dependencies]
serde_ubj = { version = "0.2.0", default-features = false, features = ["embedded-io"] }
embedded-io = { version = "latest" }
Coming soon.