pub enum CompressedReader {
Uncompressed {
slice: Buffer<u8>,
offset: usize,
},
Gzip(MultiGzDecoder<Cursor<Buffer<u8>>>),
Zlib(ZlibDecoder<Cursor<Buffer<u8>>>),
Zstd(Decoder<'static, Cursor<Buffer<u8>>>),
}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<Cursor<Buffer<u8>>>)
decompress only.Zlib(ZlibDecoder<Cursor<Buffer<u8>>>)
decompress only.Zstd(Decoder<'static, Cursor<Buffer<u8>>>)
decompress only.Implementations§
Source§impl CompressedReader
impl CompressedReader
pub fn try_new(slice: Buffer<u8>) -> Result<CompressedReader, PolarsError>
pub fn is_compressed(&self) -> bool
pub const fn initial_read_size() -> usize
pub const fn ideal_read_size() -> usize
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: &Buffer<u8>,
read_size: usize,
) -> Result<(Buffer<u8>, usize), Error>
pub fn read_next_slice( &mut self, prev_leftover: &Buffer<u8>, read_size: usize, ) -> Result<(Buffer<u8>, usize), Error>
Reads exactly read_size bytes if possible from the internal readers and creates a new
[Buffer] 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
[Buffer::sliced] 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.
Trait Implementations§
Source§impl Read for CompressedReader
This implementation is meant for compatibility. Use Self::read_next_slice for best
performance.
impl Read for CompressedReader
This implementation is meant for compatibility. Use Self::read_next_slice for best
performance.
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
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