pub struct FrameEncoder<W: Write> { /* private fields */ }Expand description
Snappy framed format encoder.
Wraps a writer and compresses data written to it using the Snappy framed format. Data is buffered internally and flushed as complete chunks.
§Example
use oxiarc_snappy::FrameEncoder;
use std::io::Write;
let mut compressed = Vec::new();
{
let mut encoder = FrameEncoder::new(&mut compressed);
encoder.write_all(b"Hello, World!").unwrap();
encoder.finish().unwrap();
}Implementations§
Source§impl<W: Write> FrameEncoder<W>
impl<W: Write> FrameEncoder<W>
Sourcepub fn new(inner: W) -> Self
pub fn new(inner: W) -> Self
Create a new framed encoder wrapping the given writer.
The stream identifier chunk will be written on the first write call.
Sourcepub fn with_pool(inner: W, pool: &SnappyPool) -> Self
pub fn with_pool(inner: W, pool: &SnappyPool) -> Self
Create a new framed encoder that reuses scratch buffers from pool.
All other behaviour is identical to FrameEncoder::new.
Sourcepub fn with_progress(self, handle: ProgressHandle) -> Self
pub fn with_progress(self, handle: ProgressHandle) -> Self
Attach a progress sink that will receive on_progress callbacks once
per encoded chunk.
Sourcepub fn with_cancel(self, token: CancellationToken) -> Self
pub fn with_cancel(self, token: CancellationToken) -> Self
Attach a cancellation token. The token is checked before each chunk
is written; if it has been cancelled the operation returns an I/O
error with the message "operation cancelled".
Trait Implementations§
Source§impl<W: Write> Drop for FrameEncoder<W>
impl<W: Write> Drop for FrameEncoder<W>
Source§impl<W: Write> Write for FrameEncoder<W>
impl<W: Write> Write for FrameEncoder<W>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes 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<W> !RefUnwindSafe for FrameEncoder<W>
impl<W> !UnwindSafe for FrameEncoder<W>
impl<W> Freeze for FrameEncoder<W>where
W: Freeze,
impl<W> Send for FrameEncoder<W>where
W: Send,
impl<W> Sync for FrameEncoder<W>where
W: Sync,
impl<W> Unpin for FrameEncoder<W>where
W: Unpin,
impl<W> UnsafeUnpin for FrameEncoder<W>where
W: UnsafeUnpin,
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