Encoder

Trait Encoder 

Source
pub unsafe trait Encoder {
    const CHARSET: &[u8];
    const MIN_LEN: usize;
}
Expand description

Specifies parameters for encoding random data into a valid UTF-8 String.

All provided implementations list their minimum secure length in the documentation of their unit struct, and it is highly recommended that custom implementations all do the same.

§Safety

The CHARSET field must only contain valid ascii characters, meaning that all u8 values must be in the interval [0, 128). Failure to uphold this condition will result in generation of invalid String values.

The MIN_LEN field must be at least ceil(logbase(2128)), where base is the length of the CHARSET field. Failure to uphold this condition will result in poor security of generated String values.

Required Associated Constants§

Source

const CHARSET: &[u8]

The character set of the encoder implementation.

See trait-level docs for safety comments.

Source

const MIN_LEN: usize

Shortest length String that will contain at least 128 bits of randomness.

See trait-level docs for safety comments.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Encoder for Base16

Source§

const CHARSET: &[u8] = b"0123456789ABCDEF"

Source§

const MIN_LEN: usize = 32usize

Source§

impl Encoder for Base32

Source§

const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"

Source§

const MIN_LEN: usize = 26usize

Source§

impl Encoder for Base32Hex

Source§

const CHARSET: &[u8] = b"0123456789ABCDEFGHIJKLMNOPQRSTUV"

Source§

const MIN_LEN: usize = 26usize

Source§

impl Encoder for Base62

Source§

const CHARSET: &[u8] = ALPHANUMERIC

Source§

const MIN_LEN: usize = 22usize

Source§

impl Encoder for Base64

Source§

const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Source§

const MIN_LEN: usize = 22usize

Source§

impl Encoder for Base64Url

Source§

const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"

Source§

const MIN_LEN: usize = 22usize