deser-encoding 0.9.0

Hex and base32 encodings of bytes for deser
Documentation

deser-encoding

More encodings of bytes as strings for deser: hexadecimal and base32.

deser writes bytes as base64 strings in formats without native bytes (like JSON) and provides the base64 encodings. This crate adds Hex, HexUpper, Base32, Base32NoPad, Base32Hex, Base32HexNoPad and Base32Dnssec (RFC 5155). All of them decode lowercase and uppercase letters. Like the encodings of deser they are adapters:

use deser::adapters::BytesFallback;
use deser::{Deserialize, Serialize};
use deser_encoding::Hex;

#[derive(Serialize, Deserialize)]
pub struct Blob {
    // a hex string in all formats
    #[deser(as = Hex)]
    digest: [u8; 32],
    // hex in JSON, bytes in CBOR
    #[deser(as = BytesFallback<Hex>)]
    signature: Vec<u8>,
}

They can also be used to configure how formats represent all bytes (with deser::BytesFormat::encoded::<Hex>()).

License and Links