pub struct ResourceLimits {
pub max_data_length: usize,
pub max_version: Version,
pub max_render_size: (u32, u32),
pub encoding_timeout: Option<u64>,
}Expand description
Explicit resource budgets for bounded QR-code construction.
QrCode::with_limits
applies these limits before allocating encoder state and after selecting
the resulting symbol dimensions. With the facade crate’s std feature,
encoding_timeout is checked at synchronous construction boundaries. It is
not a preemptive interrupt for an in-flight CPU step. The dimensions are the
maximum width and height of the symbol passed to a renderer; a renderer may
impose a stricter pixel budget of its own.
Fields§
§max_data_length: usizeMaximum number of input bytes accepted before parsing or allocation.
max_version: VersionMaximum normal QR version considered by automatic version selection.
max_render_size: (u32, u32)Maximum (width, height) accepted for the generated module symbol.
encoding_timeout: Option<u64>Optional synchronous encoding timeout budget in milliseconds.
None disables timeout checks. Some(0) is rejected as a malformed
budget because it cannot describe useful work.
Implementations§
Source§impl ResourceLimits
impl ResourceLimits
Sourcepub const fn new(
max_data_length: usize,
max_version: Version,
max_render_size: (u32, u32),
) -> Self
pub const fn new( max_data_length: usize, max_version: Version, max_render_size: (u32, u32), ) -> Self
Creates an explicit resource budget.
Sourcepub const fn with_encoding_timeout_millis(self, timeout_ms: u64) -> Self
pub const fn with_encoding_timeout_millis(self, timeout_ms: u64) -> Self
Returns this budget with an encoding timeout in milliseconds.
The facade crate enforces this budget at synchronous construction
boundaries when std is enabled.
Sourcepub fn validate(self) -> QrResult<()>
pub fn validate(self) -> QrResult<()>
Validates the shape of this budget without inspecting input data.
Automatic construction currently targets normal QR versions, so Micro versions are rejected here rather than being silently interpreted as a normal-version cap. Zero render dimensions cannot describe a symbol.