Skip to main content

DecoderConfig

Struct DecoderConfig 

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

Type-safe configuration builder for ZBar decoders

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

§Example

use zedbar::config::*;

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 a new configuration with sensible defaults

By default:

  • EAN-13, EAN-8, I25, DataBar, Codabar, Code39, Code93, Code128, QR, SQ are enabled
  • UPC-A, UPC-E, ISBN-10, ISBN-13 can be emitted as variants (not separately enabled)
  • Position tracking is enabled
  • Scan density is 1x1
  • Inverted image testing is disabled
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 disable_all(self) -> Self

Disable all symbologies

Useful when you want to start with a clean slate and only enable specific symbologies.

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

let config = DecoderConfig::new()
    .disable_all()
    .enable(QrCode)
    .enable(Code39);
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

§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

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

Source

pub fn set_binary<S: Symbology + SupportsBinary>( self, _: S, enabled: bool, ) -> Self

Enable or disable binary mode for 2D codes

When enabled, binary data is preserved without text conversion.

Source

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

Set uncertainty threshold for edge detection

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 upscale_small_images(self, enabled: bool) -> Self

Enable or disable automatic upscaling of small images

When enabled (the default), small images (< 200px in either dimension) are automatically upscaled before scanning to improve QR code detection. Small QR codes often have modules that are only 2-3 pixels wide, which is too small for reliable finder pattern detection.

Disable this if you want to minimize processing time and are confident your images have sufficient resolution.

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

impl Default for DecoderConfig

Source§

fn default() -> Self

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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