Skip to main content

ScanConfig

Struct ScanConfig 

Source
#[non_exhaustive]
pub struct ScanConfig {
Show 13 fields pub budget_ms: Option<u64>, pub pyramid: bool, pub direct: bool, pub enhance: bool, pub deep: bool, pub pyramid_side: u32, pub max_engine_side: u32, pub score_depth: ScoreDepth, pub score_skip_axes: Vec<StressAxis>, pub score_skip_checks: Vec<ScoreCheck>, pub alpha_background: AlphaBackground, pub alpha_palette: Vec<[u8; 3]>, pub formats: Vec<Symbology>,
}
Expand description

Stage-level scan configuration. Build from a profile preset, then adjust public fields as needed (the struct is non-exhaustive: presets are the only constructors). Clone-not-Copy: the axis-skip list is a collection.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§budget_ms: Option<u64>

Wall-clock budget in milliseconds. None = unbounded: the scan runs the full ladder, bounded only by the input-size Limits, never by time — the mode for strictly reproducible reports. Every built-in profile sets one (full 4 s · fast 800 ms · frame 80 ms) and server callers should keep a budget. A planned unit the deadline prevents does not run and the report says so (trace.budget_exhausted): a judgment it interrupts is absent, never partial. (Some(0) cuts immediately; bindings exposing a numeric budget map 0 → unbounded — see each binding’s docs.)

§pyramid: bool

S1 — decode a ≤pyramid_side downscale first (cheapest win).

§direct: bool

S2 — decode the full-resolution luma.

§enhance: bool

S3 — enhance set: otsu · invert · contrast · R/G/B channels.

§deep: bool

S4 — curated deep grid (size × contrast × binarization).

§pyramid_side: u32

Longest side of the S1 pyramid attempt.

§max_engine_side: u32

Hard cap on the longest side of ANY image handed to the engines — the wall-clock of one engine call is otherwise unbounded (a single rxing TryHarder pass on 64MP runs for minutes and is not interruptible). Detections are rescaled to original coordinates.

§score_depth: ScoreDepth

Stress-scoring depth applied after a successful decode.

§score_skip_axes: Vec<StressAxis>

Stress axes EXCLUDED from scoring — integration config for hosts where an axis is meaningless (a generated preview has no capture angle: builders skip perspective + rotation). Skipped axes never run (their stress cells are never built — real wall-clock savings) and the composite renormalizes over the axes that DID run, so the value stays 0-100 on the same contract-v3 weights. The report self-describes: score.axes carries only the axes that ran. Empty (every profile’s default) = the full six-axis contract, byte for byte. Skipping ALL axes yields no score at all (an axis-less value would be fiction) — same outcome as ScoreDepth::Off.

§score_skip_checks: Vec<ScoreCheck>

Score SECTIONS excluded from the report — the same integration seam as score_skip_axes, for report blocks instead of stress axes. A host that displays neither the correction margin nor the ISO parameters skips uec + iso15415: the wire carries null for them and the UEC-driven hints never fire. The UEC margin is still measured and caps the composite, so score.value, score.grade and the ISO overall never move — skipping checks is surface truth, never score surgery. Empty (every profile’s default) = every section runs, byte for byte.

§alpha_background: AlphaBackground

Background handling for inputs that carry transparent pixels — the flatten runs BEFORE luma conversion and RGB extraction, so every downstream stage (ladder · score · UEC · ISO) sees the composited image. Opaque inputs never enter this path: their reports stay byte-identical whatever this is set to.

§alpha_palette: Vec<[u8; 3]>

HOST palette colors probed by the placement envelope, on top of the neutral sweep — “does my design survive on MY theme/brand colors”, answered inside one scan instead of one full scan per color (alpha.envelope.palette). Probes are luma-space like the rest of the sweep and budget-bounded per probe. At most ScanConfig::MAX_ALPHA_PALETTE colors (a palette is the first caller-sized loop in the scan path — unbounded, it would be a CPU amplifier under budget_ms: None): ScanConfig::validate, which every scan runs first, refuses a longer one with QRS-006, and the bindings refuse a longer list before the core sees it, with their own argument error. Empty (every profile’s default) = the neutral sweep only.

§formats: Vec<Symbology>

The symbologies the scan looks for. Empty (every profile’s default) = every symbology the build reads. A host that only handles some of them names those: no reader of another symbology runs in any stage, and the stages that exist for the others are not planned — the native-resolution completion after a QR pyramid read when no listed symbology is outside the QR family, the deep stage when none is inside it. A listed symbology is read by the same readers, judged and reported as in an unrestricted scan, with the one difference that fewer readers imply: an unrestricted scan sets each symbol it reads aside and reads again around it, so a symbol that shares its rows with one of an unlisted symbology (two linear codes side by side) can need its neighbor listed to be read; and a UPC-A symbol read with ean13 listed and upc_a not is the EAN-13 it also is (a leading zero). The report says what it looked for (trace.formats).

Implementations§

Source§

impl ScanConfig

Source

pub const MAX_ALPHA_PALETTE: usize = 32

Hard cap on alpha_palette (anti-DoS: a palette entry costs a composite + up to three decode attempts). ScanConfig::validate refuses a longer palette with QRS-006; every binding refuses one before the core sees it. 32 covers any real theme/brand palette with headroom.

Source

pub const MAX_BUDGET_MS: u64 = 4_294_967_295

The largest budget_ms a scan accepts: 4 294 967 295 ms (about 49.7 days), the one range every binding can carry exactly and every platform clock can add to now. A larger budget is refused (QRS-006), never silently made unbounded.

Source

pub fn validate(&self) -> Result<()>

Refuse a configuration no scan can honour (QRS-006), before any input is read: a budget above ScanConfig::MAX_BUDGET_MS, a zero pyramid or engine side, a palette above ScanConfig::MAX_ALPHA_PALETTE. crate::Scanner::scan checks it first.

§Errors

QRS-006 naming the first option out of its domain.

Source

pub fn formats_from_names<S: AsRef<str>>(names: &[S]) -> Result<Vec<Symbology>>

The symbologies named by names, for ScanConfig::formats: wire names (crate::Symbology::name: qr_code, ean13, …), in the order given. One parser for every binding, so they accept and refuse the same names.

§Errors

QRS-006 naming the first unknown name: a typo never widens the scan back to every symbology.

Source

pub fn full() -> Self

Everything on — the quality-gate profile (~4 s budget).

Source

pub fn fast() -> Self

Upload-tool profile: no deep grid (~800 ms budget).

Source

pub fn frame() -> Self

Camera-frame profile: pyramid + direct only (~80 ms budget).

Source

pub fn computes_score(&self) -> bool

Whether this configuration judges a detection at all: false for score depth ScoreDepth::Off (the frame profile) and when every stress axis is skipped — such scans publish score: null whatever they decode and whatever the budget.

Trait Implementations§

Source§

impl Clone for ScanConfig

Source§

fn clone(&self) -> Self

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 ScanConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for ScanConfig

Source§

impl PartialEq for ScanConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScanConfig

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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<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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.