The plan for base64/hex

For a project I did recently, I needed base64 encoding and decoding. Some Googling turned up the rustc-serialize crate which I got to work easily. However, learning more about the state of the Rust ecosystem, it seems that rustc-serialize is kind of deprecated, and serde is the new hotness. So I'm left wondering: where to go for my base64 needs in this brave new serde world?

Relatedly, I'm kind of wondering whether base64 is a good fit for serde. It seems like there might be two somewhat disjoint things that are both labeled serialization: (a) object/struct/structural (de)serialization like JSON/protobufs/Thrift/captainproto/msgpack/CBOR and what not, and (b) more simple encoding things like hex, base64. In Python, the former are often covered with the load/dump protocol, whereas the latter are often implemented as "codecs".

If serde turns out to not be a great fit for these kinds of things, I would appreciate any hints on things that might be relevant to the design of a crate for category (b), so that I might just start implementing such a crate.

1 Like
1 Like

I've been using the data-encoding crate as my goto for simple encodings like this — I discovered it when I needed a base32 transcoder for playing with two-factor authentication (the standard Google Authenticator TOTP URI encodes the secret key as RFC 4648 Base32).