Skip to main content

QrCodeBuilder

Struct QrCodeBuilder 

Source
pub struct QrCodeBuilder<D: AsRef<[u8]>> { /* private fields */ }
Expand description

A builder for QrCode, offering ergonomic, chainable configuration.

Construct one with QrCode::builder. The builder delegates to the existing constructors, so its output is identical to calling them directly.

Implementations§

Source§

impl<D: AsRef<[u8]>> QrCodeBuilder<D>

Source

pub fn ec_level(self, ec_level: EcLevel) -> Self

Sets the error correction level (default EcLevel::M).

Source

pub fn version(self, version: Version) -> Self

Pins a specific QR Version. When set, build() behaves like QrCode::with_version. If micro is also set, the explicit version takes precedence.

Source

pub fn micro(self, yes: bool) -> Self

Requests a Micro QR code (the smallest fitting Micro version), behaving like QrCode::micro_with_error_correction_level when no explicit version is set.

Source

pub fn encoding_mode(self, mode: Mode) -> Self

Hints the encoding Mode (e.g. Mode::Byte), bypassing automatic mode optimization. When a version is also set it is used directly; otherwise the smallest fitting version for that mode is auto-selected.

The data must be encodable in the chosen mode: Mode::Kanji validates its Shift-JIS pairs and Mode::Byte accepts anything, but Mode::Numeric / Mode::Alphanumeric assume their input already matches (as automatic optimization would never select them otherwise).

Source

pub fn force_mode(self, mode: Mode) -> Self

Forces a specific encoding Mode, bypassing automatic optimization. This is an alias for encoding_mode, provided for familiarity with the QR-code vocabulary.

Source

pub fn build(self) -> QrResult<QrCode>

Builds the QrCode.

§Errors

Propagates any QrError from the underlying encoder (e.g. data too long, or an incompatible version / error-correction combination).

Trait Implementations§

Source§

impl<D: Clone + AsRef<[u8]>> Clone for QrCodeBuilder<D>

Source§

fn clone(&self) -> QrCodeBuilder<D>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + AsRef<[u8]>> Debug for QrCodeBuilder<D>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D> Freeze for QrCodeBuilder<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for QrCodeBuilder<D>
where D: RefUnwindSafe,

§

impl<D> Send for QrCodeBuilder<D>
where D: Send,

§

impl<D> Sync for QrCodeBuilder<D>
where D: Sync,

§

impl<D> Unpin for QrCodeBuilder<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for QrCodeBuilder<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for QrCodeBuilder<D>
where D: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.