Open rw opened 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.
@josephglanville It would be very convenient for this library to impl serde::Serialize and serde::Deserialize, so that users could use serde derive automagically. :-]
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.
Has anyone tried this approach? https://riptutorial.com/rust/example/20152/implement-serialize-and-deserialize-for-a-type-in-a-different-crate
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 Serialize
impl.
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?