[][src]Macro data_encoding_macro::new_encoding

macro_rules! new_encoding {
    ($($arg: tt)*) => { ... };
}

Defines a compile-time custom encoding

This macro takes a list of key: value, pairs (the last comma is required). The possible key-value pairs are:

            symbols: <string>,       // e.g. "01234567"
            padding: [None]|<char>,  // e.g. '='
          bit_order: [MostSignificantFirst]|LeastSignificantFirst,
check_trailing_bits: [true]|false,
             ignore: [""]|<string>,  // e.g. " \t\n"
         wrap_width: [0]|<int>,      // e.g. 76
     wrap_separator: [""]|<string>,  // e.g. "\r\n"
     translate_from: [""]|<string>,  // e.g. "ABCDEF"
       translate_to: [""]|<string>,  // e.g. "abcdef"

Only symbols is required. Everything else is optional and defaults to the value between square brackets.

Examples

extern crate data_encoding;
#[macro_use]
extern crate data_encoding_macro;

const HEX: data_encoding::Encoding = new_encoding! {
    symbols: "0123456789abcdef",
    ignore: " \r\t\n",
    wrap_width: 32,
    wrap_separator: "\n",
    translate_from: "ABCDEF",
    translate_to: "abcdef",
};