pub struct ZstdEncoder<W> { /* private fields */ }
Expand description
A zstd encoder, or compressor.
This structure implements an AsyncWrite
interface and will
take in uncompressed data and write it compressed to an underlying stream.
Implementations§
Source§impl<W> ZstdEncoder<W>where
W: AsyncWrite,
impl<W> ZstdEncoder<W>where
W: AsyncWrite,
Sourcepub fn new(inner: W) -> ZstdEncoder<W>
pub fn new(inner: W) -> ZstdEncoder<W>
Creates a new encoder which will take in uncompressed data and write it compressed to the given stream.
Sourcepub fn with_quality(inner: W, level: Level) -> ZstdEncoder<W>
pub fn with_quality(inner: W, level: Level) -> ZstdEncoder<W>
Creates a new encoder which will take in uncompressed data and write it compressed to the given stream.
Sourcepub fn with_quality_and_params(
inner: W,
level: Level,
params: &[CParameter],
) -> ZstdEncoder<W>
pub fn with_quality_and_params( inner: W, level: Level, params: &[CParameter], ) -> ZstdEncoder<W>
Creates a new encoder, using the specified compression level and parameters, which will read uncompressed data from the given stream and emit a compressed stream.
§Panics
Panics if this function is called with a CParameter::nb_workers()
parameter and
the zstdmt
crate feature is not enabled.
Sourcepub fn with_dict(
inner: W,
level: Level,
dictionary: &[u8],
) -> Result<ZstdEncoder<W>, Error>
pub fn with_dict( inner: W, level: Level, dictionary: &[u8], ) -> Result<ZstdEncoder<W>, Error>
Creates a new encoder, using the specified compression level and pre-trained dictionary, which will read uncompressed data from the given stream and emit a compressed stream.
Dictionaries provide better compression ratios for small files, but are required to be present during decompression.
§Errors
Returns error when dictionary
is not valid.
Source§impl<W> ZstdEncoder<W>
impl<W> ZstdEncoder<W>
Sourcepub fn get_ref(&self) -> &W
pub fn get_ref(&self) -> &W
Acquires a reference to the underlying writer that this encoder is wrapping.
Sourcepub fn get_mut(&mut self) -> &mut W
pub fn get_mut(&mut self) -> &mut W
Acquires a mutable reference to the underlying writer that this encoder is wrapping.
Note that care must be taken to avoid tampering with the state of the writer which may otherwise confuse this encoder.
Sourcepub fn get_pin_mut(self: Pin<&mut ZstdEncoder<W>>) -> Pin<&mut W>
pub fn get_pin_mut(self: Pin<&mut ZstdEncoder<W>>) -> Pin<&mut W>
Acquires a pinned mutable reference to the underlying writer that this encoder is wrapping.
Note that care must be taken to avoid tampering with the state of the writer which may otherwise confuse this encoder.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes this encoder returning the underlying writer.
Note that this may discard internal state of this encoder, so care should be taken to avoid losing resources when this is called.
Trait Implementations§
Source§impl<W> AsyncBufRead for ZstdEncoder<W>where
W: AsyncBufRead,
impl<W> AsyncBufRead for ZstdEncoder<W>where
W: AsyncBufRead,
Source§impl<W> AsyncRead for ZstdEncoder<W>where
W: AsyncRead,
impl<W> AsyncRead for ZstdEncoder<W>where
W: AsyncRead,
Source§impl<W> AsyncWrite for ZstdEncoder<W>where
W: AsyncWrite,
impl<W> AsyncWrite for ZstdEncoder<W>where
W: AsyncWrite,
Source§fn poll_write(
self: Pin<&mut ZstdEncoder<W>>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut ZstdEncoder<W>>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf
into the object. Read moreSource§fn poll_flush(
self: Pin<&mut ZstdEncoder<W>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut ZstdEncoder<W>>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_shutdown(
self: Pin<&mut ZstdEncoder<W>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut ZstdEncoder<W>>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write
, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read moreSource§impl<W> Debug for ZstdEncoder<W>where
W: Debug,
impl<W> Debug for ZstdEncoder<W>where
W: Debug,
impl<'__pin, W> Unpin for ZstdEncoder<W>where
<PinnedFieldsOfHelperStruct<__Origin<'__pin, W>> as PinnedFieldsOfHelperTrait>::Actual: Unpin,
Auto Trait Implementations§
impl<W> Freeze for ZstdEncoder<W>where
W: Freeze,
impl<W> RefUnwindSafe for ZstdEncoder<W>where
W: RefUnwindSafe,
impl<W> Send for ZstdEncoder<W>where
W: Send,
impl<W> Sync for ZstdEncoder<W>where
W: Sync,
impl<W> !UnwindSafe for ZstdEncoder<W>
Blanket Implementations§
Source§impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for Rwhere
R: AsyncBufRead + ?Sized,
Source§fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntil<'a, Self>where
Self: Unpin,
fn read_until<'a>(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8>,
) -> ReadUntil<'a, Self>where
Self: Unpin,
Source§fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self>where
Self: Unpin,
fn read_line<'a>(&'a mut self, buf: &'a mut String) -> ReadLine<'a, Self>where
Self: Unpin,
Source§fn split(self, byte: u8) -> Split<Self>
fn split(self, byte: u8) -> Split<Self>
byte
. Read moreSource§fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self>where
Self: Unpin,
Source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
Source§fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
fn read_buf<'a, B>(&'a mut self, buf: &'a mut B) -> ReadBuf<'a, Self, B>
Source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf
. Read moreSource§fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
fn read_u8(&mut self) -> ReadU8<&mut Self>where
Self: Unpin,
Source§fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
fn read_i8(&mut self) -> ReadI8<&mut Self>where
Self: Unpin,
Source§fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
fn read_u16(&mut self) -> ReadU16<&mut Self>where
Self: Unpin,
Source§fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
fn read_i16(&mut self) -> ReadI16<&mut Self>where
Self: Unpin,
Source§fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
fn read_u32(&mut self) -> ReadU32<&mut Self>where
Self: Unpin,
Source§fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
fn read_i32(&mut self) -> ReadI32<&mut Self>where
Self: Unpin,
Source§fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
fn read_u64(&mut self) -> ReadU64<&mut Self>where
Self: Unpin,
Source§fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
fn read_i64(&mut self) -> ReadI64<&mut Self>where
Self: Unpin,
Source§fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
fn read_u128(&mut self) -> ReadU128<&mut Self>where
Self: Unpin,
Source§fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
fn read_i128(&mut self) -> ReadI128<&mut Self>where
Self: Unpin,
Source§fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
fn read_f32(&mut self) -> ReadF32<&mut Self>where
Self: Unpin,
Source§fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
fn read_f64(&mut self) -> ReadF64<&mut Self>where
Self: Unpin,
Source§fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
fn read_u16_le(&mut self) -> ReadU16Le<&mut Self>where
Self: Unpin,
Source§fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
fn read_i16_le(&mut self) -> ReadI16Le<&mut Self>where
Self: Unpin,
Source§fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
fn read_u32_le(&mut self) -> ReadU32Le<&mut Self>where
Self: Unpin,
Source§fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
fn read_i32_le(&mut self) -> ReadI32Le<&mut Self>where
Self: Unpin,
Source§fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
fn read_u64_le(&mut self) -> ReadU64Le<&mut Self>where
Self: Unpin,
Source§fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
fn read_i64_le(&mut self) -> ReadI64Le<&mut Self>where
Self: Unpin,
Source§fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
fn read_u128_le(&mut self) -> ReadU128Le<&mut Self>where
Self: Unpin,
Source§fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
fn read_i128_le(&mut self) -> ReadI128Le<&mut Self>where
Self: Unpin,
Source§fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
fn read_f32_le(&mut self) -> ReadF32Le<&mut Self>where
Self: Unpin,
Source§fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
fn read_f64_le(&mut self) -> ReadF64Le<&mut Self>where
Self: Unpin,
Source§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
buf
. Read more