RoaringBitmap / roaring-rs

A better compressed bitset in Rust
https://docs.rs/roaring/
Apache License 2.0
763 stars 84 forks source link

Serde support? #59

Open rw opened 4 years ago

rw commented 4 years ago

It would be useful to have built-in serde support for storing and retrieving bitmaps from this library. Could the existing serialization functions be used to implement this efficiently?

josephglanville commented 4 years ago

The existing serialisation functions are good for reading/writing to byte buffers/files etc. I'm not sure exactly what serde support entails however but assuming it's about either writing to files or transmitting across the network then yes, the existing functions are good + efficient.

rw commented 4 years ago

@josephglanville It would be very convenient for this library to impl serde::Serialize and serde::Deserialize, so that users could use serde derive automagically. :-]

Nemo157 commented 4 years ago

This should be relatively trivial to implement, though unfortunately because of serde's design it will require serializing the entire bitmap into a Vec<u8> before writing to the serializer.

ingberam commented 2 years ago

Has anyone tried this approach? https://riptutorial.com/rust/example/20152/implement-serialize-and-deserialize-for-a-type-in-a-different-crate

saik0 commented 2 years ago

One consideration is human readable formats.

It's not immediately obvious how to do serde from a binary format into a human readable one. For example, default behavior of serde_json is to encode it as a json array of numbers: serde-rs/json#360. Users would likely need to use something like serde_with or a newtype regardless if we provided a Serializeimpl.