1 unstable release

0.1.0 Mar 15, 2024

#2329 in Encoding

Download history 533/week @ 2024-06-02 363/week @ 2024-06-09 291/week @ 2024-06-16 383/week @ 2024-06-23 651/week @ 2024-06-30 542/week @ 2024-07-07 390/week @ 2024-07-14 749/week @ 2024-07-21 485/week @ 2024-07-28 515/week @ 2024-08-04 371/week @ 2024-08-11 379/week @ 2024-08-18 624/week @ 2024-08-25 783/week @ 2024-09-01 681/week @ 2024-09-08 599/week @ 2024-09-15

2,703 downloads per month

MIT license

8KB
50 lines

base64-bytes

Binary blobs with intelligent serialization.

Where Vec<u8> always serializes as an array of bytes, this crate provides serialization functions which try to make an intelligent decision about how to serialize a byte vector based on the serialization format.

For binary formats like bincode, the array-of-bytes serialization works great: it is compact and introduces very little overhead. But for human-readable types such as json, it's far from ideal. The text encoding of an array introduces substantial overhead, and the resulting array of opaque bytes isn't particularly readable anyways.

base64-bytes uses the is_human_readable property of a serializer to distinguish these cases. For binary formats, it uses the default Vec<u8> serialization. For human-readable formats, it uses a much more compact and conventional base 64 encoding.

Dependencies

~325–580KB
~12K SLoC