Enum qrcode::types::Mode [] [src]

pub enum Mode {
    Numeric,
    Alphanumeric,
    Byte,
    Kanji,
}

The mode indicator, which specifies the character set of the encoded data.

Variants

Numeric

The data contains only characters 0 to 9.

Alphanumeric

The data contains only uppercase letters (A–Z), numbers (0–9) and a few punctuations marks (space, $, %, *, +, -, ., /, :).

Byte

The data contains arbitrary binary data.

Kanji

The data contains Shift-JIS-encoded double-byte text.

Methods

impl Mode
[src]

fn length_bits_count(&self, version: Version) -> usize

Computes the number of bits needed to encode the data length.

use qrcode::types::{Version, Mode};

assert_eq!(Mode::Numeric.length_bits_count(Version::Normal(1)), 10);

This method will return Err(QrError::UnsupportedCharacterSet) if the mode is not supported in the given version.

fn data_bits_count(&self, raw_data_len: usize) -> usize

Computes the number of bits needed to some data of a given raw length.

use qrcode::types::Mode;

assert_eq!(Mode::Numeric.data_bits_count(7), 24);

Note that in Kanji mode, the raw_data_len is the number of Kanjis, i.e. half the total size of bytes.

fn max(&self, other: Mode) -> Mode

Find the lowest common mode which both modes are compatible with.

use qrcode::types::Mode;

let a = Mode::Numeric;
let b = Mode::Kanji;
let c = a.max(b);
assert!(a <= c);
assert!(b <= c);

Trait Implementations

impl PartialOrd for Mode
[src]

fn partial_cmp(&self, other: &Mode) -> Option<Ordering>

Defines a partial ordering between modes. If a <= b, then b contains a superset of all characters supported by a.

fn lt(&self, other: &Rhs) -> bool
1.0.0

This method tests less than (for self and other) and is used by the < operator. Read more

fn le(&self, other: &Rhs) -> bool
1.0.0

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

fn gt(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than (for self and other) and is used by the > operator. Read more

fn ge(&self, other: &Rhs) -> bool
1.0.0

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Derived Implementations

impl Clone for Mode
[src]

fn clone(&self) -> Mode

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Copy for Mode
[src]

impl Eq for Mode
[src]

impl PartialEq for Mode
[src]

fn eq(&self, __arg_0: &Mode) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Rhs) -> bool
1.0.0

This method tests for !=.

impl Debug for Mode
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.