Enum MemoryLimit
pub enum MemoryLimit
The maximum amount of memory the decoder is allowed to use for each frame
Variants
-
Unlimited Enforce no memory limit.
If you intend to process images from unknown origins this is a potentially dangerous constant to use, as your program could be vulnerable to decompression bombs. That is, malicious images crafted specifically to require an enormous amount of memory to process while having a disproportionately small file size.
The risks for modern machines are a bit smaller as the size of each frame cannot exceed 16GiB, but this is still a significant amount of memory.
-
Bytes(NonZeroU64) Limit the amount of memory that can be used for a single frame to this many bytes.
It may not be enforced precisely due to allocator overhead and the decoder potentially allocating small auxiliary buffers, but it will precisely limit the size of the output buffer for each frame.
Trait Implementations
impl Clone for MemoryLimit
fn clone(&self) -> MemoryLimit
impl Debug for MemoryLimit
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl Freeze for MemoryLimit
impl RefUnwindSafe for MemoryLimit
impl Send for MemoryLimit
impl Sync for MemoryLimit
impl Unpin for MemoryLimit
impl UnsafeUnpin for MemoryLimit
impl UnwindSafe for MemoryLimit
Blanket Implementations
impl<T> Any for MemoryLimit
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for MemoryLimit
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for MemoryLimit
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for MemoryLimit
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for MemoryLimit
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for MemoryLimit
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for MemoryLimit
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for MemoryLimit
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for MemoryLimit
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>