Struct fast_qr::qr::QRCode

source ·
pub struct QRCode {
    pub data: [Module; 31329],
    pub size: usize,
    pub version: Option<Version>,
    pub ecl: Option<ECL>,
    pub mask: Option<Mask>,
    pub mode: Option<Mode>,
}
Expand description

A QRCode can be created using QRBuilder. Simple API for simple usage. If you need to use QRCode directly, please file an issue on github explaining your use case.

Contains all needed information about the QRCode. This is the main struct of the crate.

It contains the matrix of the QRCode, stored as a one-dimensional array.

Fields§

§data: [Module; 31329]

This array length is of size 177 x 177. It is using a fixed size array simply because of performance.

§Other data type possible:

  • Templated Matrix was faster but crate size was huge.
  • Vector using with_capacity, really bad.
§size: usize

Width & Height of QRCode. If manually set, should be version * 4 + 17, version going from 1 to 40 both included.

§version: Option<Version>

Version of the QRCode, impacts the size.

None will optimize Version according to ECL and Mode

§ecl: Option<ECL>

Defines how powerful QRCode redundancy should be or how much percent of a QRCode can be recovered.

  • ECL::L: 7%
  • ECL::M: 15%
  • ECL::Q: 25%
  • ELC::H: 30%

None will set ECL to Quartile (ELC::Q)

§mask: Option<Mask>

Changes the final pattern used.

None will find the best suited mask.

§mode: Option<Mode>

Mode defines which data is being parsed, between Numeric, AlphaNumeric & Byte.

None will optimize Mode according to user input.

§Note

Kanji mode is not supported (yet).

Implementations§

source§

impl QRCode

source

pub const fn default(size: usize) -> Self

A default QRCode will have all it’s fields as None and a default Matrix filled with Module::LIGHT.

source§

impl QRCode

source

pub fn to_str(&self) -> String

Prints the QRCode to the terminal

source

pub fn print(&self)

Prints the QRCode to the terminal

Trait Implementations§

source§

impl Clone for QRCode

source§

fn clone(&self) -> QRCode

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 QRCode

source§

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

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

impl Index<usize> for QRCode

§

type Output = [Module]

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for QRCode

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl Freeze for QRCode

§

impl RefUnwindSafe for QRCode

§

impl Send for QRCode

§

impl Sync for QRCode

§

impl Unpin for QRCode

§

impl UnwindSafe for QRCode

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.