pub struct Encoder { /* private fields */ }qr only.Expand description
Configures and encodes Model 2 QR Code symbols.
Implementations§
Source§impl QrEncoder
impl QrEncoder
Sourcepub const fn new(error_correction: QrErrorCorrection) -> Self
pub const fn new(error_correction: QrErrorCorrection) -> Self
Creates an encoder with automatic mask selection and Model 2 versions 1 through 40.
Sourcepub const fn version(self, version: QrVersion) -> Self
pub const fn version(self, version: QrVersion) -> Self
Selects one exact Model 2 QR Code version.
Sourcepub const fn version_range(self, versions: RangeInclusive<QrVersion>) -> Self
pub const fn version_range(self, versions: RangeInclusive<QrVersion>) -> Self
Selects the inclusive Model 2 QR Code version range considered during encoding.
Sourcepub const fn mask(self, mask: QrMask) -> Self
pub const fn mask(self, mask: QrMask) -> Self
Forces an exact mask instead of selecting one automatically.
Sourcepub const fn boost_error_correction(self, boost: bool) -> Self
pub const fn boost_error_correction(self, boost: bool) -> Self
Enables or disables upgrading the error correction level when the selected version has room.
Sourcepub const fn fnc1(self, fnc1: Option<Fnc1>) -> Self
pub const fn fnc1(self, fnc1: Option<Fnc1>) -> Self
Sets the FNC1 interpretation applied to the complete symbol.
Sourcepub fn encode_bytes(
&self,
data: impl AsRef<[u8]>,
) -> Result<Symbol, EncodeError>
pub fn encode_bytes( &self, data: impl AsRef<[u8]>, ) -> Result<Symbol, EncodeError>
Encodes raw bytes with globally optimized Numeric, Alphanumeric and Byte segments.
Sourcepub fn encode_text(&self, text: impl AsRef<str>) -> Result<Symbol, EncodeError>
pub fn encode_text(&self, text: impl AsRef<str>) -> Result<Symbol, EncodeError>
Encodes text with globally optimized character modes and ECI transitions.
Sourcepub fn encode_to_qr_text<T: ToQRText + ?Sized>(
&self,
value: &T,
) -> Result<Symbol, EncodeError>
pub fn encode_to_qr_text<T: ToQRText + ?Sized>( &self, value: &T, ) -> Result<Symbol, EncodeError>
Encodes a value after converting it to its QR Code text representation.
Sourcepub fn encode_segments(
&self,
segments: &[Segment],
) -> Result<Symbol, EncodeError>
pub fn encode_segments( &self, segments: &[Segment], ) -> Result<Symbol, EncodeError>
Encodes explicit segments without changing their boundaries.
Sourcepub fn encode_structured_append_bytes(
&self,
parts: &[&[u8]],
) -> Result<Vec<Symbol>, EncodeError>
pub fn encode_structured_append_bytes( &self, parts: &[&[u8]], ) -> Result<Vec<Symbol>, EncodeError>
Encodes caller-selected byte parts as one Structured Append sequence.
Sourcepub fn encode_structured_append_text(
&self,
parts: &[&str],
) -> Result<Vec<Symbol>, EncodeError>
pub fn encode_structured_append_text( &self, parts: &[&str], ) -> Result<Vec<Symbol>, EncodeError>
Encodes caller-selected text parts as one Structured Append sequence.
Sourcepub fn encode_structured_append_segments(
&self,
parts: &[&[Segment]],
) -> Result<Vec<Symbol>, EncodeError>
pub fn encode_structured_append_segments( &self, parts: &[&[Segment]], ) -> Result<Vec<Symbol>, EncodeError>
Encodes caller-selected segment parts as one Structured Append sequence.
Sourcepub fn encode_bytes_with_structured_append(
&self,
data: impl AsRef<[u8]>,
) -> Result<Vec<Symbol>, EncodeError>
pub fn encode_bytes_with_structured_append( &self, data: impl AsRef<[u8]>, ) -> Result<Vec<Symbol>, EncodeError>
Encodes bytes as one symbol or automatically splits them into at most 16 Structured Append symbols.
When the data fits one symbol, that lone symbol is returned without Structured Append metadata, because a single symbol needs no sequence header.
Sourcepub fn encode_text_with_structured_append(
&self,
text: impl AsRef<str>,
) -> Result<Vec<Symbol>, EncodeError>
pub fn encode_text_with_structured_append( &self, text: impl AsRef<str>, ) -> Result<Vec<Symbol>, EncodeError>
Encodes text as one symbol or automatically splits it into at most 16 Structured Append symbols.
When the text fits one symbol, that lone symbol is returned without Structured Append metadata, because a single symbol needs no sequence header.