pub enum CompressedReader {
Uncompressed {
slice: MemSlice,
offset: usize,
},
Gzip(MultiGzDecoder<MemReader>),
Zlib(ZlibDecoder<MemReader>),
Zstd(Decoder<'static, MemReader>),
}polars-io only.Expand description
Reader that implements a streaming read trait for uncompressed, gzip, zlib and zstd compression.
This allows handling decompression transparently in a streaming fashion.
Variants§
Uncompressed
Gzip(MultiGzDecoder<MemReader>)
Zlib(ZlibDecoder<MemReader>)
Zstd(Decoder<'static, MemReader>)
Implementations§
Source§impl CompressedReader
impl CompressedReader
pub fn try_new(slice: MemSlice) -> Result<CompressedReader, PolarsError>
pub fn is_compressed(&self) -> bool
Sourcepub fn total_len_estimate(&self) -> usize
pub fn total_len_estimate(&self) -> usize
If possible returns the total number of bytes that will be produced by reading from the start to finish.
Sourcepub fn read_next_slice(
&mut self,
prev_leftover: &MemSlice,
read_size: usize,
) -> Result<(MemSlice, usize), Error>
pub fn read_next_slice( &mut self, prev_leftover: &MemSlice, read_size: usize, ) -> Result<(MemSlice, usize), Error>
Reads exactly read_size bytes if possible from the internal readers and creates a new
MemSlice with the content concat(prev_leftover, new_bytes).
Returns the new slice and the number of bytes read, which will be 0 when eof is reached and this function is called again.
If the underlying reader is uncompressed the operation is a cheap zero-copy
MemSlice::slice operation.
By handling slice concatenation at this level we can implement zero-copy reading and make the interface easier to use.
It’s a logic bug if prev_leftover is neither empty nor the last slice returned by this
function.
Auto Trait Implementations§
impl !Freeze for CompressedReader
impl !RefUnwindSafe for CompressedReader
impl Send for CompressedReader
impl Sync for CompressedReader
impl Unpin for CompressedReader
impl !UnwindSafe for CompressedReader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more