deser

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.
```rust
use deser::{Serialize, Deserialize};
[derive(Debug, Serialize, Deserialize)]
[deser(rename_all = "camelCase")]
pub struct Account {
id: usize,
accountholder: String,
isdeactivated: bool,
}
```
This generates out the necessary
Serialize
and
Deserialize
implementations.
To see what this looks like behind the scenes there are two examples
that show how structs are implemented:
- derive: shows an example using automatic deriving
- manual-struct: shows the same example with a manual implementation
Design Goals
- Fast Compile Times: deser avoids excessive monomorphization by encouraging dynamic dispatch.
- Unlimited Recursion: the real world is nasty and incoming data might be badly nested.
Do not exhaust the call stack no matter how deep your data is.
It accomplishes this by an alternative trait design to serde where
handles to "sinks" or "serializable" objects are returned. This
means that it's up to the caller to manage the recursion.
- Simple Data Model: deser simplifies the data model on the serialization
and deserialization interface. For instance instead of making a distinction
between
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.
- Meta Information: deser compensates the simplified data model with providing
a space to hold meta information. This for instance can be used to automatically
keep track of the "path" to the current structure during serialization and
deserialization.
- Native Byte Serialization: deser has built-in specialization for serializing
bytes and byte vectors as distinct formats from slices and vectors.
Future Plans
- Extensible Data Model: deser wants to make it possible to extend the data
model with types that are not native to the serialization interface. For
instance if a data format wants to support arbitrarily sized integers this
should be possible without falling back to in-band
signalling.
Crates
- deser: the core crate
providing the base functionality
- deser-path: a crate
that extends deser to track the path during serialization
- deser-debug: formats
a serializable to the
std::fmt
debug format
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