Enum png::encoder::Wrapper

source ·
enum Wrapper<'a, W: Write> {
    Chunk(ChunkWriter<'a, W>),
    Zlib(ZlibEncoder<ChunkWriter<'a, W>>),
    Unrecoverable,
    None,
}
Expand description

This enum is used to be allow the StreamWriter to keep its inner ChunkWriter without wrapping it inside a ZlibEncoder. This is used in the case that between the change of state that happens when the last write of a frame is performed an error occurs, which obviously has to be returned. This creates the problem of where to store the writer before exiting the function, and this is where Wrapper comes in.

Unfortunately the ZlibWriter can’t be used because on the write following the error, finish would be called and that would write some data even if 0 bytes where compressed.

If the finish function fails then there is nothing much to do as the ChunkWriter would get lost so the Unrecoverable variant is used to signal that.

Variants§

§

Chunk(ChunkWriter<'a, W>)

§

Zlib(ZlibEncoder<ChunkWriter<'a, W>>)

§

Unrecoverable

§

None

This is used in-between, should never be matched

Implementations§

source§

impl<'a, W: Write> Wrapper<'a, W>

source

fn take(&mut self) -> Wrapper<'a, W>

Like Option::take this returns the Wrapper contained in self and replaces it with Wrapper::None

Auto Trait Implementations§

§

impl<'a, W> RefUnwindSafe for Wrapper<'a, W>where W: RefUnwindSafe,

§

impl<'a, W> Send for Wrapper<'a, W>where W: Send,

§

impl<'a, W> Sync for Wrapper<'a, W>where W: Sync,

§

impl<'a, W> Unpin for Wrapper<'a, W>where W: Unpin,

§

impl<'a, W> !UnwindSafe for Wrapper<'a, W>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.