Struct Decoder
pub struct Decoder<R: BufRead + Seek> { /* private fields */ }
PNG Decoder
Implementations
impl<R: BufRead + Seek> Decoder<R>
fn new(r: R) -> Decoder<R>Create a new decoder configuration with default limits.
fn new_with_limits(r: R, limits: Limits) -> Decoder<R>Create a new decoder configuration with custom limits.
fn new_with_options(r: R, decode_options: DecodeOptions) -> Decoder<R>Create a new decoder configuration with custom
DecodeOptions.fn set_limits(&mut self, limits: Limits)Limit resource usage.
Note that your allocations, e.g. when reading into a pre-allocated buffer, are NOT considered part of the limits. Nevertheless, required intermediate buffers such as for singular lines is checked against the limit.
Note that this is a best-effort basis.
use File; use BufReader; use ; // This image is 32×32, 1bit per pixel. The reader buffers one row which requires 4 bytes. let mut limits = default; limits.bytes = 3; let mut decoder = new_with_limits; assert!; // This image is 32x32 pixels, so the decoder will allocate less than 10Kib let mut limits = default; limits.bytes = 10*1024; let mut decoder = new_with_limits; assert!;fn read_header_info(&mut self) -> Result<&Info<'static>, DecodingError>Read the PNG header and return the information contained within.
Most image metadata will not be read until
read_infois called, so those fields will be None or empty.fn read_info(self) -> Result<Reader<R>, DecodingError>Reads all meta data until the first IDAT chunk
fn set_transformations(&mut self, transform: Transformations)Set the allowed and performed transformations.
A transformation is a pre-processing on the raw image data modifying content or encoding. Many options have an impact on memory or CPU usage during decoding.
fn set_ignore_text_chunk(&mut self, ignore_text_chunk: bool)Set the decoder to ignore all text chunks while parsing.
eg.
use File; use BufReader; use Decoder; let mut decoder = new; decoder.set_ignore_text_chunk; assert!;fn set_ignore_iccp_chunk(&mut self, ignore_iccp_chunk: bool)Set the decoder to ignore iccp chunks while parsing.
eg.
use File; use BufReader; use Decoder; let mut decoder = new; decoder.set_ignore_iccp_chunk; assert!;fn ignore_checksums(&mut self, ignore_checksums: bool)Set the decoder to ignore and not verify the Adler-32 checksum and CRC code.
Auto Trait Implementations
impl<R> Freeze for Decoder<R>
where
ReadDecoder<R>: Freeze,
impl<R> RefUnwindSafe for Decoder<R>
where
ReadDecoder<R>: RefUnwindSafe,
impl<R> Send for Decoder<R>
where
ReadDecoder<R>: Send,
impl<R> Sync for Decoder<R>
where
ReadDecoder<R>: Sync,
impl<R> Unpin for Decoder<R>
where
ReadDecoder<R>: Unpin,
impl<R> UnsafeUnpin for Decoder<R>
where
ReadDecoder<R>: UnsafeUnpin,
impl<R> UnwindSafe for Decoder<R>
where
ReadDecoder<R>: UnwindSafe,
Blanket Implementations
impl<T> Any for Decoder<R>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Decoder<R>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Decoder<R>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Decoder<R>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Decoder<R>
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 Decoder<R>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Decoder<R>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>