Struct weezl::encode::Encoder [−][src]
pub struct Encoder { /* fields omitted */ }
The state for encoding data with an LZW algorithm.
The same structure can be utilized with streams as well as your own buffers and driver logic. It may even be possible to mix them if you are sufficiently careful not to lose any written data in the process.
Implementations
impl Encoder
[src]
impl Encoder
[src]pub fn new(order: BitOrder, size: u8) -> Self
[src]
Create a new encoder with the specified bit order and symbol size.
The algorithm for dynamically increasing the code symbol bit width is compatible with the
original specification. In particular you will need to specify an Lsb
bit oder to encode
the data portion of a compressed gif
image.
Panics
The size
needs to be in the interval 2..=12
.
pub fn with_tiff_size_switch(order: BitOrder, size: u8) -> Self
[src]
Create a TIFF compatible encoder with the specified bit order and symbol size.
The algorithm for dynamically increasing the code symbol bit width is compatible with the TIFF specification, which is a misinterpretation of the original algorithm for increasing the code size. It switches one symbol sooner.
Panics
The size
needs to be in the interval 2..=12
.
pub fn encode_bytes(&mut self, inp: &[u8], out: &mut [u8]) -> BufferResult
[src]
Encode some bytes from inp
into out
.
See into_stream
for high-level functions (this interface is only available with the
std
feature) and finish
for marking the input data as complete.
When some input byte is invalid, i.e. is not smaller than 1 << size
, then that byte and
all following ones will not be consumed and the status
of the result will signal an
error. The result will also indicate that all bytes up to but not including the offending
byte have been consumed. You may try again with a fixed byte.
pub fn into_stream<W: Write>(&mut self, writer: W) -> IntoStream<'_, W>
[src]
Construct a encoder into a writer.
pub fn finish(&mut self)
[src]
Mark the encoding as in the process of finishing.
The next following call to encode_bytes
which is able to consume the complete input will
also try to emit an end code. It’s not recommended, but also not unsound, to use different
byte slices in different calls from this point forward and thus to ‘delay’ the actual end
of the data stream. The behaviour after the end marker has been written is unspecified but
sound.
pub fn reset(&mut self)
[src]
Reset all internal state.
This produce an encoder as if just constructed with new
but taking slightly less work. In
particular it will not deallocate any internal allocations. It will also avoid some
duplicate setup work.