This library provides macros to define compile-time byte slices and arrays from encoded strings (using common bases like base64, base32, or hexadecimal, and also custom bases). It also provides a macro to define compile-time custom encodings to be used with the data-encoding crate.
If you were familiar with the binary_macros crate, this library is actually inspired from it.
If you use a nightly compiler, you may disable the "stable" feature:
data-encoding-macro = { version = "0.1.0", default-features = false }
Examples
You can define a compile-time byte slice or array (using the hexlower
or
base64
macros for example):
const HELLO: &'static = &hexlower!;
const FOOBAR: &'static = &base64!;
// In nightly, it is possible to define an array instead of a slice:
hexlower_array!;
base64_array!;
You can define a compile-time custom encoding using the new_encoding
macro:
const HEX: Encoding = new_encoding!;
const BASE64: Encoding = new_encoding!;
See the documentation for more details.