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),
) -> ResourceLimits
pub const fn new( max_data_length: usize, max_version: Version, max_render_size: (u32, u32), ) -> ResourceLimits
Creates an explicit resource budget.
Sourcepub const fn with_encoding_timeout_millis(
self,
timeout_ms: u64,
) -> ResourceLimits
pub const fn with_encoding_timeout_millis( self, timeout_ms: u64, ) -> ResourceLimits
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) -> Result<(), QrError>
pub fn validate(self) -> Result<(), QrError>
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.
Trait Implementations§
Source§impl Clone for ResourceLimits
impl Clone for ResourceLimits
Source§fn clone(&self) -> ResourceLimits
fn clone(&self) -> ResourceLimits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ResourceLimits
Source§impl Debug for ResourceLimits
impl Debug for ResourceLimits
Source§impl Default for ResourceLimits
impl Default for ResourceLimits
Source§fn default() -> ResourceLimits
fn default() -> ResourceLimits
Source§impl<'de> Deserialize<'de> for ResourceLimits
impl<'de> Deserialize<'de> for ResourceLimits
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ResourceLimits, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ResourceLimits, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for ResourceLimits
Source§impl PartialEq for ResourceLimits
impl PartialEq for ResourceLimits
Source§impl Serialize for ResourceLimits
impl Serialize for ResourceLimits
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ResourceLimits
Auto Trait Implementations§
impl Freeze for ResourceLimits
impl RefUnwindSafe for ResourceLimits
impl Send for ResourceLimits
impl Sync for ResourceLimits
impl Unpin for ResourceLimits
impl UnsafeUnpin for ResourceLimits
impl UnwindSafe for ResourceLimits
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 more