[−][src]Struct ruzstd::frame_decoder::FrameDecoder
Methods
impl FrameDecoder
[src]
ⓘImportant traits for FrameDecoderpub fn new() -> FrameDecoder
[src]
This will create a new decoder without allocating anything yet. init()/reset() will allocate all needed buffers if it is the first time this decoder is used else they just reset these buffers with not further allocations
pub fn init(&mut self, source: &mut dyn Read) -> Result<(), String>
[src]
init() will allocate all needed buffers if it is the first time this decoder is used else they just reset these buffers with not further allocations
Note that all bytes currently in the decodebuffer from any previous frame will be lost. Collect them with collect()/collect_to_writer()
equivalent to reset()
pub fn init_with_dict(
&mut self,
source: &mut dyn Read,
dict: &[u8]
) -> Result<(), String>
[src]
&mut self,
source: &mut dyn Read,
dict: &[u8]
) -> Result<(), String>
Like init but provides the dict to use for the next frame
pub fn reset(&mut self, source: &mut dyn Read) -> Result<(), String>
[src]
reset() will allocate all needed buffers if it is the first time this decoder is used else they just reset these buffers with not further allocations
Note that all bytes currently in the decodebuffer from any previous frame will be lost. Collect them with collect()/collect_to_writer()
equivalent to init()
pub fn reset_with_dict(
&mut self,
source: &mut dyn Read,
dict: &[u8]
) -> Result<(), String>
[src]
&mut self,
source: &mut dyn Read,
dict: &[u8]
) -> Result<(), String>
Like reset but provides the dict to use for the next frame
pub fn add_dict(&mut self, raw_dict: &[u8]) -> Result<(), String>
[src]
Add a dict to the FrameDecoder that can be used when needed. The FrameDecoder uses the appropriate one dynamically
pub fn content_size(&self) -> Option<u64>
[src]
Returns how many bytes the frame contains after decompression
pub fn get_checksum_from_data(&self) -> Option<u32>
[src]
Returns the checksum that was read from the data. Only available after all bytes have been read. It is the last 4 bytes of a zstd-frame
pub fn get_calculated_checksum(&self) -> Option<u32>
[src]
Returns the checksum that was calculated while decoding. Only a sensible value after all decoded bytes have been collected/read from the FrameDecoder
pub fn bytes_read_from_source(&self) -> u64
[src]
Counter for how many bytes have been consumed while deocidng the frame
pub fn is_finished(&self) -> bool
[src]
Whether the current frames last block has been decoded yet If this returns true you can call the drain* functions to get all content (the read() function will drain automatically if this returns true)
pub fn blocks_decoded(&self) -> usize
[src]
Counter for how many blocks have already been decoded
pub fn decode_blocks(
&mut self,
source: &mut dyn Read,
strat: BlockDecodingStrategy
) -> Result<bool, FrameDecoderError>
[src]
&mut self,
source: &mut dyn Read,
strat: BlockDecodingStrategy
) -> Result<bool, FrameDecoderError>
Decodes blocks from a reader. It requires that the framedecoder has been initialized first. The Strategy influences how many blocks will be decoded before the function returns This is important if you want to manage memory consumption carefully. If you dont care about that you can just choose the strategy "All" and have all blocks of the frame decoded into the buffer
pub fn collect(&mut self) -> Option<Vec<u8>>
[src]
Collect bytes and retain window_size bytes while decoding is still going on. After decoding of the frame (is_finished() == true) has finished it will collect all remaining bytes
pub fn collect_to_writer(&mut self, w: &mut dyn Write) -> Result<usize, Error>
[src]
Collect bytes and retain window_size bytes while decoding is still going on. After decoding of the frame (is_finished() == true) has finished it will collect all remaining bytes
pub fn can_collect(&self) -> usize
[src]
How many bytes can currently be collected from the decodebuffer, while decoding is going on this will be lower than the ectual decodbuffer size because window_size bytes need to be retained for decoding. After decoding of the frame (is_finished() == true) has finished it will report all remaining bytes
pub fn decode_from_to(
&mut self,
source: &[u8],
target: &mut [u8]
) -> Result<(usize, usize), FrameDecoderError>
[src]
&mut self,
source: &[u8],
target: &mut [u8]
) -> Result<(usize, usize), FrameDecoderError>
Decodes as many blocks as possible from the source slice and reads from the decodebuffer into the target slice The source slice may contain only parts of a frame but must contain at least one full block to make progress
By all means use decode_blocks if you have a io.Reader available. This is just for compatibility with other decompressors which try to serve an old-style c api
Returns (read, written), if read == 0 then the source did not contain a full block and further calls with the same input will not make any progress!
Note that no kind of block can be bigger than 128kb. So to be safe use at least 128*1024 (max block content size) + 3 (block_header size) + 18 (max frame_header size) bytes as your source buffer
You may call this function with an empty source after all bytes have been decoded. This is equivalent to just call decoder.read(&mut traget)
Trait Implementations
impl Default for FrameDecoder
[src]
impl Read for FrameDecoder
[src]
Read bytes from the decode_buffer that are no longer needed. While the frame is not yet finished this will retain window_size bytes, else it will drain it completely
fn read(&mut self, target: &mut [u8]) -> Result<usize, Error>
[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut]) -> Result<usize, Error>
1.36.0[src]
unsafe fn initializer(&self) -> Initializer
[src]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn bytes(self) -> Bytes<Self>
1.0.0[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
Auto Trait Implementations
impl Send for FrameDecoder
impl Sync for FrameDecoder
impl Unpin for FrameDecoder
impl UnwindSafe for FrameDecoder
impl RefUnwindSafe for FrameDecoder
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<R> ReadBytesExt for R where
R: Read + ?Sized,
[src]
R: Read + ?Sized,
fn read_u8(&mut self) -> Result<u8, Error>
[src]
fn read_i8(&mut self) -> Result<i8, Error>
[src]
fn read_u16<T>(&mut self) -> Result<u16, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i16<T>(&mut self) -> Result<i16, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u24<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i24<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u32<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i32<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u48<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i48<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u64<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i64<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u128<T>(&mut self) -> Result<u128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i128<T>(&mut self) -> Result<i128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_f32<T>(&mut self) -> Result<f32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_f64<T>(&mut self) -> Result<f64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i8_into(&mut self, dst: &mut [i8]) -> Result<(), Error>
[src]
fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_f64_into<T>(&mut self, dst: &mut [f64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
fn read_f64_into_unchecked<T>(&mut self, dst: &mut [f64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,