Skip to main content

DecoderConfig

Struct DecoderConfig 

Source
pub struct DecoderConfig { /* private fields */ }
Expand description

Type-safe configuration builder for zedbar decoders

This builder uses the type system to ensure only valid configurations can be set for each symbology type.

Start from DecoderConfig::new() (empty — opt in to each symbology you want) or DecoderConfig::all() (full kitchen-sink for exploratory use).

§Example

use zedbar::config::*;
use zedbar::DecoderConfig;

let config = DecoderConfig::new()
    .enable(Ean13)
    .enable(Code39)
    .set_checksum(Code39, true, false)
    .set_length_limits(Code39, 4, 20)
    .position_tracking(true);

Implementations§

Source§

impl DecoderConfig

Source

pub fn new() -> Self

Create an empty configuration with no symbologies enabled.

Opt in to each symbology you want via enable; only the decoders you ask for will run.

Global scanner settings (position tracking, scan density, etc.) are initialized to sensible defaults; per-symbology config (length limits, checksum behavior, uncertainty) for variants like UPC-A, UPC-E, ISBN-10, and ISBN-13 is preconfigured so that enabling them produces reasonable output.

§Example
use zedbar::config::*;
use zedbar::DecoderConfig;

let config = DecoderConfig::new()
    .enable(QrCode);
Source

pub fn all() -> Self

Create a configuration with the full set of supported symbologies enabled.

Enables EAN-13, EAN-8, I2/5, DataBar, DataBar-Expanded, Codabar, Code 39, Code 93, Code 128, QR Code, and SQ Code. UPC-A, UPC-E, ISBN-10, and ISBN-13 are not enabled — they can be opted in as variant labels of EAN-13/EAN-8 via enable.

Prefer new() and explicit enable calls when you know which formats you need.

§Example
use zedbar::DecoderConfig;

let config = DecoderConfig::all();
Source

pub fn enable<S: Symbology + SupportsEnable>(self, _: S) -> Self

Enable a symbology

Source

pub fn disable<S: Symbology + SupportsEnable>(self, _: S) -> Self

Disable a symbology

Source

pub fn enable_type(self, sym: SymbolType) -> Self

Enable a symbology by its runtime SymbolType.

Prefer enable when the symbology is known at compile time — it carries the SupportsEnable capability bound. This runtime variant is for callers parsing config from strings, CLI flags, or other dynamic sources.

Source

pub fn is_enabled(&self, sym: SymbolType) -> bool

Check if a symbology is enabled

Source

pub fn set_checksum<S: Symbology + SupportsChecksum>( self, _: S, add_check: bool, emit_check: bool, ) -> Self

Configure checksum behavior for a symbology, enabling it if not already enabled.

§Arguments
  • add_check - Validate checksum during decoding
  • emit_check - Include checksum digit in decoded data
Source

pub fn set_length_limits<S: Symbology + SupportsLengthLimits>( self, _: S, min: u32, max: u32, ) -> Self

Set minimum and maximum length limits, enabling the symbology if not already enabled.

Only valid for variable-length symbologies like Code39, Code128, etc.

Source

pub fn set_uncertainty<S: Symbology + SupportsUncertainty>( self, _: S, threshold: u32, ) -> Self

Set uncertainty threshold for edge detection, enabling the symbology if not already enabled.

Higher values are more tolerant of poor quality images but may produce more false positives.

Source

pub fn position_tracking(self, enabled: bool) -> Self

Enable or disable position tracking

When enabled, the scanner records the pixel coordinates of each detected symbol.

Source

pub fn test_inverted(self, enabled: bool) -> Self

Enable or disable inverted image testing

When enabled, if no symbols are found in the normal image, the scanner will try again with an inverted (negative) image.

Source

pub fn scan_density(self, x: u32, y: u32) -> Self

Set scan density for both axes

Higher density means more scan lines, which improves detection but increases processing time. A value of 1 means scan every line.

Source

pub fn retry_undecoded_regions(self, enabled: bool) -> Self

Automatically retry undecoded QR finder regions by cropping and upscaling them.

When enabled, if the initial scan detects QR finder patterns but fails to decode the QR code (e.g. because it is too small), the scanner will crop each undecoded region with padding, upscale it at several resolutions, and re-scan. Decoded symbol coordinates are mapped back to the original image frame.

Default: false.

Source

pub fn x_density(self, density: u32) -> Self

Set horizontal scan density

Source

pub fn y_density(self, density: u32) -> Self

Set vertical scan density

Trait Implementations§

Source§

impl Clone for DecoderConfig

Source§

fn clone(&self) -> DecoderConfig

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 Debug for DecoderConfig

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V