mitsuhiko / deser

Experimental rust serialization library
https://docs.rs/deser
Apache License 2.0
289 stars 8 forks source link
rust serialization

deser: an experimental serialization and deserialization library for Rust

Crates.io License Documentation

Deser is an experimental serialization system for Rust. It wants to explore the possibilities of serialization and deserialization of structural formats such as JSON or msgpack. It intentionally does not desire to support non self describing formats such as bincode.

This is not a production ready yet.

use deser::{Serialize, Deserialize};

#[derive(Debug, Serialize, Deserialize)]
#[deser(rename_all = "camelCase")]
pub struct Account {
    id: usize,
    account_holder: String,
    is_deactivated: bool,
}

This generates out the necessary Serialize and Deserialize implementations.

To see some practical examples of this have a look at the examples.

Design Goals

Deser does not intend on replacing serde but it attempts to address some if it's shortcomings. For more information there is a document about Serde Learnings with more details.

Future Plans

Known Limitations

The current design of this system is very allocation heavy. This is the consequence of a certain level of flexibility paired with the dynamic dispatch nature. For instance for JSON parsing, Serde is more than 3 times faster than Deser and for deserialization 2.5 times.

Crates

Inspiration

This crate heavily borrows from miniserde, serde and Sentry Relay's meta system. The general trait design was modelled after miniserde.

Safety

Deser (currently) uses excessive amounts of unsafe code internally. It is not vetted and it is likely completely wrong. If this design turns out to be useful there will be need to be a re-design of the internals.

License and Links