Struct image::io::Limits

source · []
pub struct Limits {
    pub max_image_width: Option<u32>,
    pub max_image_height: Option<u32>,
    pub max_alloc: Option<u64>,
    /* private fields */
}
Expand description

Resource limits for decoding.

Limits can be either strict or non-strict. Non-strict limits are best-effort limits where the library does not guarantee that limit will not be exceeded. Do note that it is still considered a bug if a non-strict limit is exceeded, however as some of the underlying decoders do not support not support such limits one cannot rely on these limits being supported. For stric limits the library makes a stronger guarantee that the limit will not be exceeded. Exceeding a strict limit is considered a critical bug. If a decoder cannot guarantee that it will uphold a strict limit it must fail with image::error::LimitErrorKind::Unsupported.

Currently the only strict limits supported are the max_image_width and max_image_height limits, however more will be added in the future. LimitSupport will default to support being false and decoders should enable support for the limits they support in ImageDecoder::set_limits.

The limit check should only ever fail if a limit will be exceeded or an unsupported strict limit is used.

Fields

max_image_width: Option<u32>

The maximum allowed image width. This limit is strict. The default is no limit.

max_image_height: Option<u32>

The maximum allowed image height. This limit is strict. The default is no limit.

max_alloc: Option<u64>

The maximum allowed sum of allocations allocated by the decoder at any one time exluding allocator overhead. This limit is non-strict by default and some decoders may ignore it. The default is 512MiB.

Implementations

Disable all limits.

This function checks that all currently set strict limits are supported.

This function checks the max_image_width and max_image_height limits given the image width and height.

This function checks that the current limit allows for reserving the set amount of bytes, it then reduces the limit accordingly.

This function acts identically to [reserve], but takes a usize for convenience.

This function increases the max_alloc limit with amount. Should only be used together with reserve.

This function acts identically to [free], but takes a usize for convenience.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.