Macro const_base::encode [−][src]
macro_rules! encode { ($slice : expr, $config : expr $(,) *) => { ... }; }
Expand description
Encodes the $slice constant into a &[u8; N] with the encoding determined by $config.
$slice slice can be a &'static str, &'static [u8; N], or &'static [u8].
Examples
Base 64
use const_base::{encode, Config}; { const OUT: &[u8; 4] = encode!("bar", Config::B64); assert_eq!(OUT, b"YmFy"); } { const BYTES: &[u8] = b"world"; // this macro can encode non-literal constants const OUT: &[u8] = encode!(BYTES, Config::B64_URL_SAFE); assert_eq!(OUT, b"d29ybGQ="); }