Skip to main content

Alphabet

Trait Alphabet 

Source
pub trait Alphabet {
    const ENCODE: [u8; 64];

    // Required method
    fn decode(byte: u8) -> Option<u8>;

    // Provided method
    fn encode(value: u8) -> u8 { ... }
}
Expand description

A Base64 alphabet.

Required Associated Constants§

Source

const ENCODE: [u8; 64]

Encoding table indexed by 6-bit values.

Required Methods§

Source

fn decode(byte: u8) -> Option<u8>

Decode one byte into a 6-bit value.

Provided Methods§

Source

fn encode(value: u8) -> u8

Encode one 6-bit value into an alphabet byte.

The default implementation scans the alphabet table instead of using a secret-indexed table lookup. Built-in alphabets override this with the branch-minimized ASCII arithmetic mapper. Custom alphabets that keep the default method prioritize timing posture over throughput: every emitted Base64 byte performs a fixed 64-entry scan. For massive payloads with user-defined alphabets, profile this cost and consider an audited custom override only if the alphabet has a structure that can be mapped without secret-indexed table access.

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§