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
impl DecoderConfig
Sourcepub fn new() -> Self
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);Sourcepub fn all() -> Self
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();Sourcepub fn enable<S: Symbology + SupportsEnable>(self, _: S) -> Self
pub fn enable<S: Symbology + SupportsEnable>(self, _: S) -> Self
Enable a symbology
Sourcepub fn disable<S: Symbology + SupportsEnable>(self, _: S) -> Self
pub fn disable<S: Symbology + SupportsEnable>(self, _: S) -> Self
Disable a symbology
Sourcepub fn enable_type(self, sym: SymbolType) -> Self
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.
Sourcepub fn is_enabled(&self, sym: SymbolType) -> bool
pub fn is_enabled(&self, sym: SymbolType) -> bool
Check if a symbology is enabled
Sourcepub fn set_checksum<S: Symbology + SupportsChecksum>(
self,
_: S,
add_check: bool,
emit_check: bool,
) -> Self
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 decodingemit_check- Include checksum digit in decoded data
Sourcepub fn set_length_limits<S: Symbology + SupportsLengthLimits>(
self,
_: S,
min: u32,
max: u32,
) -> Self
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.
Sourcepub fn set_uncertainty<S: Symbology + SupportsUncertainty>(
self,
_: S,
threshold: u32,
) -> Self
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.
Sourcepub fn position_tracking(self, enabled: bool) -> Self
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.
Sourcepub fn test_inverted(self, enabled: bool) -> Self
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.
Sourcepub fn scan_density(self, x: u32, y: u32) -> Self
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.
Sourcepub fn retry_undecoded_regions(self, enabled: bool) -> Self
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.
Trait Implementations§
Source§impl Clone for DecoderConfig
impl Clone for DecoderConfig
Source§fn clone(&self) -> DecoderConfig
fn clone(&self) -> DecoderConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more