Skip to main content

EncodingMode

Trait EncodingMode 

Source
pub trait EncodingMode {
    const MODE: Mode;

    // Required methods
    fn validate(data: &[u8]) -> bool;
    fn invalid_character(data: &[u8]) -> Option<(usize, u8)>;
    fn bits_per_character() -> f64;

    // Provided method
    fn character_count(data: &[u8]) -> usize { ... }
}
Expand description

A type-level QR encoding mode.

Required Associated Constants§

Source

const MODE: Mode

Runtime mode represented by this marker type.

Required Methods§

Source

fn validate(data: &[u8]) -> bool

Returns whether data is valid for this mode.

Source

fn invalid_character(data: &[u8]) -> Option<(usize, u8)>

Returns the first invalid byte for this mode, if any.

Source

fn bits_per_character() -> f64

Approximate payload bits per logical character for this mode.

Provided Methods§

Source

fn character_count(data: &[u8]) -> usize

Returns the number of logical characters represented by data.

This differs from data.len() for Kanji mode, where every character is represented by two Shift-JIS bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl EncodingMode for AlphanumericMode

Source§

const MODE: Mode = Mode::Alphanumeric

Source§

impl EncodingMode for ByteMode

Source§

const MODE: Mode = Mode::Byte

Source§

impl EncodingMode for KanjiMode

Source§

const MODE: Mode = Mode::Kanji

Source§

impl EncodingMode for NumericMode

Source§

const MODE: Mode = Mode::Numeric