Struct zstd::stream::write::Encoder [−][src]
pub struct Encoder<'a, W: Write> { /* fields omitted */ }
Expand description
An encoder that compress and forward data to another writer.
This allows to compress a stream of data (good for files or heavy network stream).
Don’t forget to call finish()
before dropping it!
Note: The zstd library has its own internal input buffer (~128kb).
Implementations
Creates a new encoder.
level
: compression level (1-21).
A level of 0
uses zstd’s default (currently 3
).
Creates a new encoder, using an existing dictionary.
(Provides better compression ratio for small files, but requires the dictionary to be present during decompression.)
A level of 0
uses zstd’s default (currently 3
).
pub fn with_prepared_dictionary<'b>(
writer: W,
dictionary: &EncoderDictionary<'b>
) -> Result<Self> where
'b: 'a,
[src]
pub fn with_prepared_dictionary<'b>(
writer: W,
dictionary: &EncoderDictionary<'b>
) -> Result<Self> where
'b: 'a,
[src]Creates a new encoder, using an existing prepared EncoderDictionary
.
(Provides better compression ratio for small files, but requires the dictionary to be present during decompression.)
pub fn auto_finish(self) -> AutoFinishEncoder<'a, W>ⓘNotable traits for AutoFinishEncoder<'_, W>
impl<W: Write> Write for AutoFinishEncoder<'_, W>
[src]
pub fn auto_finish(self) -> AutoFinishEncoder<'a, W>ⓘNotable traits for AutoFinishEncoder<'_, W>
impl<W: Write> Write for AutoFinishEncoder<'_, W>
[src]Returns a wrapper around self
that will finish the stream on drop.
Panic
Panics on drop if an error happens when finishing the stream.
pub fn on_finish<F: 'static + FnMut(Result<W>)>(
self,
f: F
) -> AutoFinishEncoder<'a, W>ⓘNotable traits for AutoFinishEncoder<'_, W>
impl<W: Write> Write for AutoFinishEncoder<'_, W>
[src]
pub fn on_finish<F: 'static + FnMut(Result<W>)>(
self,
f: F
) -> AutoFinishEncoder<'a, W>ⓘNotable traits for AutoFinishEncoder<'_, W>
impl<W: Write> Write for AutoFinishEncoder<'_, W>
[src]Returns an encoder that will finish the stream on drop.
Calls the given callback with the result from finish()
.
Acquires a mutable reference to the underlying writer.
Note that mutation of the writer may result in surprising results if this encoder is continued to be used.
Required: Finishes the stream.
You need to finish the stream when you’re done writing, either with
this method or with try_finish(self)
.
This returns the inner writer in case you need it.
To get back self
in case an error happened, use try_finish
.
Note: If you don’t want (or can’t) call finish()
manually after
writing your data, consider using auto_finish()
to get an
AutoFinishEncoder
.
Required: Attempts to finish the stream.
You need to finish the stream when you’re done writing, either with
this method or with finish(self)
.
This returns the inner writer if the finish was successful, or the object plus an error if it wasn’t.
write
on this object will panic after try_finish
has been called,
even if it fails.
Attemps to finish the stream.
You need to finish the stream when you’re done writing, either with
this method or with finish(self)
.
Return a recommendation for the size of data to write at once.
Sets the given zstd compression parameter.
Controls whether zstd should include a content checksum at the end of each frame.
Enables multithreaded compression
- If
n_workers == 0
(default), then multithreaded will be disabled. - If
n_workers >= 1
, then compression will be done in separate threads.
So even n_workers = 1
may increase performance by separating
IO and compression.
Enables or disables storing of the dict id.
Defaults to true. If false, the behaviour of decoding with a wrong dictionary is undefined.
Enables or disabled storing of the contentsize
Enables or disables long-distance matching
Sets the maximum back-reference distance.
The actual maximum distance is going to be 2^log_distance
.
Enables or disable the magic bytes at the beginning of each frame.
If disabled, include_magicbytes must also be called on the decoder.
Only available with the experimental
feature.
Trait Implementations
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
Attempts to write an entire buffer into this writer. Read more
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Auto Trait Implementations
impl<'a, W> RefUnwindSafe for Encoder<'a, W> where
W: RefUnwindSafe,
impl<'a, W> UnwindSafe for Encoder<'a, W> where
W: UnwindSafe,