Crates.io | deser-derive |
lib.rs | deser-derive |
version | 0.8.0 |
source | src |
created_at | 2022-02-05 15:34:51.624024 |
updated_at | 2022-02-19 16:12:32.218465 |
description | Derive extension for deser |
homepage | |
repository | https://github.com/mitsuhiko/deser |
max_upload_size | |
id | 527475 |
size | 68,646 |
deser: an experimental serialization and deserialization library for Rust
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.
u8
and u64
they are represented the same in the model. To compensate
for this, it provides type descriptors that provide auxiliary information for
when a serializer wants to process it. This helps with compile times and makes
using the crate easier.Vec<u8>
is serialized as bytes and does not need
special handling for text-only formats such as JSON.#[deser(flatten)]
.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.
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.
std::fmt
debug formatThis crate heavily borrows from
miniserde
,
serde
and Sentry Relay's meta
system. The general trait design was
modelled after miniserde
.
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.