Relrin / bert-rs

BERT (Binary ERlang Term) serializer for Rust
BSD 3-Clause "New" or "Revised" License
15 stars 1 forks source link

Add Serde support #1

Open dtolnay opened 8 years ago

dtolnay commented 8 years ago

As suggested by Shepmaster in http://stackoverflow.com/a/38804932/6086311.

Providing a Serde Serializer and Deserializer would give your crate an API that is consistent with tons of existing Rust data formats (JSON, Bincode, CBOR, YAML, MessagePack, Pickle, Hjson, XML, many others).

Also it would allow me to serialize my own types to BERT:

#[derive(Serialize, Deserialize)]
struct Point {
    x: f64,
    y: f64,
}

let pt = Point { x: 2.3, y: 4.5 };
let result = bert::serialize(&pt);

which is much nicer than having to use BertTuple all over my own crate or having to convert my structs to BertTuple before serializing them.

Relrin commented 8 years ago

Hi, dtolnay!

Thank you for opening the issue here. I've overlooked the serde-rs library, but found a lot different issues which disturb me:

But from the other side, this let to use crate easily, if it will be a part of the serde-rs crate, as plugin. I'm agree with this proposal. However, I'm really don't want to support a behaviour, which is not described at the bert-rpc document. For example:

And so on...

dtolnay commented 8 years ago

Thanks for the feedback.

Again, the whole point is so that I can use BERT without doing either of these unpleasant things:

Serde support would allow me to use BERT with my own data structures used in the rest of my program.

dtolnay commented 8 years ago

Looks good so far! Once you publish the first release containing Serde support, I will add a link to this repo at https://serde.rs/.

Relrin commented 7 years ago

@dtolnay I'm going to make a release for v0.1 or bert-rs crate. At the moment it will be support only serialize from Rust types to the Erlang format. Could you help me to write remaining deserializers (especially where I have troubles)? For deserializers all what has left: list / tuples, BertBigInteger and special kind of tuples which represented as {bert, ...}