Struct qrcodegen::QrSegment[][src]

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

A segment of character/binary/control data in a QR Code symbol.

Instances of this struct are immutable.

The mid-level way to create a segment is to take the payload data and call a static factory function such as QrSegment::make_numeric(). The low-level way to create a segment is to custom-make the bit buffer and call the QrSegment::new() constructor with appropriate values.

This segment struct imposes no length restrictions, but QR Codes have restrictions. Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. Any segment longer than this is meaningless for the purpose of generating QR Codes.

Implementations

Returns a segment representing the given binary data encoded in byte mode.

All input byte slices are acceptable.

Any text string can be converted to UTF-8 bytes and encoded as a byte mode segment.

Returns a segment representing the given string of decimal digits encoded in numeric mode.

Panics if the string contains non-digit characters.

Returns a segment representing the given text string encoded in alphanumeric mode.

The characters allowed are: 0 to 9, A to Z (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.

Panics if the string contains non-encodable characters.

Returns a list of zero or more segments to represent the given Unicode text string.

The result may use various segment modes and switch modes to optimize the length of the bit stream.

Returns a segment representing an Extended Channel Interpretation (ECI) designator with the given assignment value.

Creates a new QR Code segment with the given attributes and data.

The character count (numchars) must agree with the mode and the bit buffer length, but the constraint isn’t checked.

Returns the mode indicator of this segment.

Returns the character count field of this segment.

Returns the data bits of this segment.

Tests whether the given string can be encoded as a segment in numeric mode.

A string is encodable iff each character is in the range 0 to 9.

Tests whether the given string can be encoded as a segment in alphanumeric mode.

A string is encodable iff each character is in the following set: 0 to 9, A to Z (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.

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.