Struct libflate::finish::AutoFinish
source · pub struct AutoFinish<T: Complete> { /* private fields */ }
Expand description
A wrapper struct that completes the processing of the underlying instance when drops.
This calls Complete:::complete
method of T
when drops.
§Panics
If the invocation of Complete::complete(T)
returns an error, AutoFinish::drop()
will panic.
Implementations§
source§impl<T: Complete> AutoFinish<T>
impl<T: Complete> AutoFinish<T>
sourcepub fn new(inner: T) -> Self
pub fn new(inner: T) -> Self
Makes a new AutoFinish
instance.
§Examples
#[cfg(feature = "no_std")]
use core2::io::Write;
#[cfg(not(feature = "no_std"))]
use std::io::Write;
use libflate::finish::AutoFinish;
use libflate::gzip::Encoder;
let plain = b"Hello World!";
let mut buf = Vec::new();
let mut encoder = AutoFinish::new(Encoder::new(&mut buf).unwrap());
encoder.write_all(plain.as_ref()).unwrap();
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwraps this AutoFinish
instance, returning the underlying instance.
Trait Implementations§
source§impl<T: Complete> Deref for AutoFinish<T>
impl<T: Complete> Deref for AutoFinish<T>
source§impl<T: Complete> DerefMut for AutoFinish<T>
impl<T: Complete> DerefMut for AutoFinish<T>
source§impl<T: Complete> Drop for AutoFinish<T>
impl<T: Complete> Drop for AutoFinish<T>
source§impl<T: Complete + Write> Write for AutoFinish<T>
impl<T: Complete + Write> Write for AutoFinish<T>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<T> Freeze for AutoFinish<T>where
T: Freeze,
impl<T> RefUnwindSafe for AutoFinish<T>where
T: RefUnwindSafe,
impl<T> Send for AutoFinish<T>where
T: Send,
impl<T> Sync for AutoFinish<T>where
T: Sync,
impl<T> Unpin for AutoFinish<T>where
T: Unpin,
impl<T> UnwindSafe for AutoFinish<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more