Struct Encoder
struct Encoder<'a, R> { ... }
An encoder that compress input data from another Read.
Implementations
impl<'a, R: BufRead> Encoder<'a, R>
fn with_prepared_dictionary<'b>(reader: R, dictionary: &EncoderDictionary<'b>) -> Result<Self> where 'b: 'aCreates a new encoder, using an existing
EncoderDictionary.The dictionary must be the same as the one used during compression.
fn recommended_output_size() -> usizeRecommendation for the size of the output buffer.
fn get_ref(self: &Self) -> &RAcquire a reference to the underlying reader.
fn get_mut(self: &mut Self) -> &mut RAcquire a mutable reference to the underlying reader.
Note that mutation of the reader may result in surprising results if this encoder is continued to be used.
fn flush(self: &mut Self, out: &mut [u8]) -> Result<usize>Flush any internal buffer.
This ensures all input consumed so far is compressed.
Since it prevents bundling currently buffered data with future input, it may affect compression ratio.
- Returns the number of bytes written to
out. - Returns
Ok(0)when everything has been flushed.
- Returns the number of bytes written to
fn finish(self: Self) -> RReturn the inner
Read.Calling
finish()is not required after reading a stream - just use it if you need to get theReadback.fn set_parameter(self: &mut Self, parameter: CParameter) -> Result<()>Sets the given zstd compression parameter.
fn set_pledged_src_size(self: &mut Self, size: Option<u64>) -> Result<()>Sets the expected size of the input.
This affects the compression effectiveness.
It is an error to give an incorrect size (an error will be returned when closing the stream if the size does not match what was pledged).
Giving a
Nonesize means the size is unknown (this is the default).fn include_checksum(self: &mut Self, include_checksum: bool) -> Result<()>Controls whether zstd should include a content checksum at the end of each frame.
fn include_dictid(self: &mut Self, include_dictid: bool) -> Result<()>Enables or disables storing of the dict id.
Defaults to true. If false, the behaviour of decoding with a wrong dictionary is undefined.
fn include_contentsize(self: &mut Self, include_contentsize: bool) -> Result<()>Enables or disabled storing of the contentsize.
Note that this only has an effect if the size is given with
set_pledged_src_size.fn long_distance_matching(self: &mut Self, long_distance_matching: bool) -> Result<()>Enables or disables long-distance matching
fn set_target_cblock_size(self: &mut Self, target_size: Option<u32>) -> Result<()>Sets the target size for compressed blocks.
A lower block size may result in slightly lower speed (~2%) and compression ratio (~0.1%), but may decrease end-to-end latency in low-bandwidth environments (time to first decompressed byte).
No value, or a value of zero, results in no contraint for the block sizes.
fn window_log(self: &mut Self, log_distance: u32) -> Result<()>Sets the maximum back-reference distance.
The actual maximum distance is going to be
2^log_distance.Note that decompression will need to use at least the same setting.
impl<R: BufRead> Encoder<'static, R>
fn with_buffer(reader: R, level: i32) -> Result<Self>Creates a new encoder around a
BufRead.fn with_dictionary(reader: R, level: i32, dictionary: &[u8]) -> Result<Self>Creates a new encoder, using an existing dictionary.
The dictionary must be the same as the one used during compression.
impl<R: Read> Encoder<'static, BufReader<R>>
fn new(reader: R, level: i32) -> Result<Self>Creates a new encoder.
impl<'a, R> Freeze for Encoder<'a, R>
impl<'a, R> RefUnwindSafe for Encoder<'a, R>
impl<'a, R> Send for Encoder<'a, R>
impl<'a, R> Sync for Encoder<'a, R>
impl<'a, R> Unpin for Encoder<'a, R>
impl<'a, R> UnsafeUnpin for Encoder<'a, R>
impl<'a, R> UnwindSafe for Encoder<'a, R>
impl<R: BufRead> Read for Encoder<'_, R>
fn read(self: &mut Self, buf: &mut [u8]) -> Result<usize>
impl<T> Any for Encoder<'a, R>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Encoder<'a, R>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Encoder<'a, R>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Encoder<'a, R>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Encoder<'a, R>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Encoder<'a, R>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Encoder<'a, R>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>