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
impl DecoderConfig
Sourcepub fn new() -> Self
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
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 disable_all(self) -> Self
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);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
§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
Only valid for variable-length symbologies like Code39, Code128, etc.
Sourcepub fn set_binary<S: Symbology + SupportsBinary>(
self,
_: S,
enabled: bool,
) -> Self
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.
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
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 upscale_small_images(self, enabled: bool) -> Self
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.
Trait Implementations§
Source§impl Clone for DecoderConfig
impl Clone for DecoderConfig
Source§fn clone(&self) -> DecoderConfig
fn clone(&self) -> DecoderConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DecoderConfig
impl Debug for DecoderConfig
Auto Trait Implementations§
impl Freeze for DecoderConfig
impl RefUnwindSafe for DecoderConfig
impl Send for DecoderConfig
impl Sync for DecoderConfig
impl Unpin for DecoderConfig
impl UnwindSafe for DecoderConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().