Enum qr_code::types::Version

source ·
pub enum Version {
    Normal(i16),
    Micro(i16),
}
Expand description

In QR code terminology, Version means the size of the generated image. Larger version means the size of code is larger, and therefore can carry more information.

The smallest version is Version::Normal(1) of size 21×21, and the largest is Version::Normal(40) of size 177×177.

Variants§

§

Normal(i16)

A normal QR code version. The parameter should be between 1 and 40.

§

Micro(i16)

A Micro QR code version. The parameter should be between 1 and 4.

Implementations§

source§

impl Version

source

pub fn width(self) -> i16

Get the number of “modules” on each size of the QR code, i.e. the width and height of the code.

source

pub fn fetch<T>(self, ec_level: EcLevel, table: &[[T; 4]]) -> QrResult<T>where T: PartialEq + Default + Copy,

Obtains an object from a hard-coded table.

The table must be a 44×4 array. The outer array represents the content for each version. The first 40 entry corresponds to QR code versions 1 to 40, and the last 4 corresponds to Micro QR code version 1 to 4. The inner array represents the content in each error correction level, in the order [L, M, Q, H].

Errors

If the entry compares equal to the default value of T, this method returns Err(QrError::InvalidVersion).

source

pub fn mode_bits_count(self) -> usize

The number of bits needed to encode the mode indicator.

source

pub fn is_micro(self) -> bool

Checks whether is version refers to a Micro QR code.

Trait Implementations§

source§

impl Clone for Version

source§

fn clone(&self) -> Version

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Version

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Version> for Version

source§

fn eq(&self, other: &Version) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Version

source§

impl Eq for Version

source§

impl StructuralEq for Version

source§

impl StructuralPartialEq for Version

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.