KokaKiwi / rust-hex

A basic crate to encode values to hexadecimal representation. Originally extracted from rustc-serialize.
https://crates.io/crates/hex
Apache License 2.0
201 stars 55 forks source link

A Struct Hex ? #47

Open Stargateur opened 4 years ago

Stargateur commented 4 years ago

Could be nice to have a struct that enforce at compile time that a string is expected to be Hex encoded.

struct HexString(String); struct HexSlice<'a>(&'a str)

The idea behind this is related to mongodb gridfs, the field md5 is expected to be Hex encoded, so I though, wouldn't be nice to have a struct that ensure a field is hex encoded ?

This is common in TLS crate for example, https://docs.rs/native-tls/0.2.4/native_tls/struct.Certificate.html.