6 releases (breaking)
Uses new Rust 2024
| 0.5.0 | May 29, 2025 |
|---|---|
| 0.4.0 | May 25, 2025 |
| 0.3.1 | May 24, 2025 |
| 0.2.2 | May 20, 2025 |
| 0.1.0 | May 10, 2025 |
#630 in Encoding
439 downloads per month
165KB
4K
SLoC
serde_sono
A serde de-/serializer for the Sono data format.
Example
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct Hobby(String);
#[derive(Deserialize, Debug)]
struct Person {
name: String,
age: u32,
hobby: Hobby,
#[serde(default)]
friends: Vec<Person>,
}
fn main() {
let input = r#"
Person {
name: "katie",
age: 10,
hobby: "reading",
friends: [
{ name: "tom", age: 33, hobby: "writing" },
Person("bea", 9, Hobby("transpiling"), []),
Person { name: "josh", hobby: "dreaming", age: 12 },
]
}
"#;
match serde_sono::from_str::<Person>(input) {
Err(e) => println!("syntax error: {e:#}"),
Ok(value) => println!("{value:#?}"),
}
}
SONO language
See https://github.com/xitep/sono
TODOs
- Pretty formatting when serializing
- Generic data model
serde_sono::Value - Efficient value skipping / ignoring
- Documentation
- Measure and tweak performance
Features
-
value: enabled by default; guards the
serde_sono::Valuetype -
lossless-serialize-value-leaking: Implements
serde::Serializeforserde_sono::Valueproducing a lossless presentation of the serialized values at the cost of leaking memory for object names and property keys to support serializes which do retain references to these.The feature is disabled by default and results in objects being serialized as lists and/or maps of their properties.
This feature is an alternative to
lossless-serialize-value-unsafe. -
lossless-serialize-value-unsafe: Implements
serde::Serializeforserde_sono::Valueproducing a lossless presentation of the serialized values by assuming that the used serializer does not retain references to the handed object and property names. (The serializer provided byserde_sono, for example, does not.)The feature is disabled by default and results in objects being serialized as lists and/or maps of their properties.
This feature is an alternative to
lossless-serialize-value-leaking.
Dependencies
~195–790KB
~15K SLoC