Struct qrcodegen::QrCode[][src]

pub struct QrCode { /* fields omitted */ }
Expand description

A QR Code symbol, which is a type of two-dimension barcode.

Invented by Denso Wave and described in the ISO/IEC 18004 standard.

Instances of this struct represent an immutable square grid of dark and light cells. The impl provides static factory functions to create a QR Code from text or binary data. The struct and impl cover the QR Code Model 2 specification, supporting all versions (sizes) from 1 to 40, all 4 error correction levels, and 4 character encoding modes.

Ways to create a QR Code object:

  • High level: Take the payload data and call QrCode::encode_text() or QrCode::encode_binary().
  • Mid level: Custom-make the list of segments and call QrCode::encode_segments() or QrCode::encode_segments_advanced().
  • Low level: Custom-make the array of data codeword bytes (including segment headers and final padding, excluding error correction codewords), supply the appropriate version number, and call the QrCode::encode_codewords() constructor.

(Note that all ways require supplying the desired error correction level.)

Implementations

Returns a QR Code representing the given Unicode text string at the given error correction level.

As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer Unicode code points (not UTF-8 code units) if the low error correction level is used. The smallest possible QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.

Returns a wrapped QrCode if successful, or Err if the data is too long to fit in any version at the given ECC level.

Returns a QR Code representing the given binary data at the given error correction level.

This function always encodes using the binary segment mode, not any text mode. The maximum number of bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.

Returns a wrapped QrCode if successful, or Err if the data is too long to fit in any version at the given ECC level.

Returns a QR Code representing the given segments at the given error correction level.

The smallest possible QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.

This function allows the user to create a custom sequence of segments that switches between modes (such as alphanumeric and byte) to encode text in less space. This is a mid-level API; the high-level API is encode_text() and encode_binary().

Returns a wrapped QrCode if successful, or Err if the data is too long to fit in any version at the given ECC level.

Returns a QR Code representing the given segments with the given encoding parameters.

The smallest possible QR Code version within the given range is automatically chosen for the output. Iff boostecl is true, then the ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. The mask number is either between 0 to 7 (inclusive) to force that mask, or None to automatically choose an appropriate mask (which may be slow).

This function allows the user to create a custom sequence of segments that switches between modes (such as alphanumeric and byte) to encode text in less space. This is a mid-level API; the high-level API is encode_text() and encode_binary().

Returns a wrapped QrCode if successful, or Err if the data is too long to fit in any version in the given range at the given ECC level.

Creates a new QR Code with the given version number, error correction level, data codeword bytes, and mask number.

This is a low-level API that most users should not use directly. A mid-level API is the encode_segments() function.

Returns this QR Code’s version, in the range [1, 40].

Returns this QR Code’s size, in the range [21, 177].

Returns this QR Code’s error correction level.

Returns this QR Code’s mask, in the range [0, 7].

Returns the color of the module (pixel) at the given coordinates, which is false for light or true for dark.

The top left corner has the coordinates (x=0, y=0). If the given coordinates are out of bounds, then false (light) is returned.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.