pub struct BufferedZigZagReader<R, P = NonStrict> { /* private fields */ }Expand description
Buffered reader for ZigZag + unsigned LEB128 integers.
Values are decoded directly from the internal input buffer while the codec scans for the underlying LEB128 terminating byte.
§Buffered state
This reader may prefetch bytes from the wrapped reader. As a result,
Self::inner can observe an underlying stream position ahead of the
logical position exposed by this wrapper, and Self::into_inner discards
any prefetched bytes that have not been consumed.
§Target-width integers
isize methods use the current Rust target’s pointer width. Prefer
fixed-width integer methods such as read_i64 for persistent files and
cross-platform protocols.
Implementations§
Source§impl<R, P> BufferedZigZagReader<R, P>where
P: DecodePolicy,
impl<R, P> BufferedZigZagReader<R, P>where
P: DecodePolicy,
Sourcepub fn new(inner: R) -> Self
pub fn new(inner: R) -> Self
Creates a buffered ZigZag reader with the default buffer capacity.
Sourcepub fn with_capacity(inner: R, capacity: usize) -> Self
pub fn with_capacity(inner: R, capacity: usize) -> Self
Creates a buffered ZigZag reader with at least capacity bytes.
Sourcepub const fn is_strict(&self) -> bool
pub const fn is_strict(&self) -> bool
Returns whether this reader rejects non-canonical LEB128 encodings.
Sourcepub const fn inner(&self) -> &R
pub const fn inner(&self) -> &R
Returns a shared reference to the underlying reader.
The underlying reader may already be positioned past unread bytes held in this wrapper’s internal buffer.
Sourcepub fn inner_mut(&mut self) -> &mut R
pub fn inner_mut(&mut self) -> &mut R
Returns an exclusive reference to the underlying reader.
Mutating the underlying reader directly can invalidate prefetched bytes already held in this wrapper’s internal buffer.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consumes this wrapper and returns the underlying reader.
Any bytes already prefetched into the internal buffer but not consumed by codec methods are discarded.
Source§impl<R> BufferedZigZagReader<R, NonStrict>where
R: Read,
impl<R> BufferedZigZagReader<R, NonStrict>where
R: Read,
Sourcepub fn read_isize(&mut self) -> Result<isize>
pub fn read_isize(&mut self) -> Result<isize>
Reads a ZigZag isize.
Source§impl<R> BufferedZigZagReader<R, Strict>where
R: Read,
impl<R> BufferedZigZagReader<R, Strict>where
R: Read,
Sourcepub fn read_isize(&mut self) -> Result<isize>
pub fn read_isize(&mut self) -> Result<isize>
Reads a ZigZag isize.
Trait Implementations§
Source§impl<R, P> Read for BufferedZigZagReader<R, P>where
R: Read,
impl<R, P> Read for BufferedZigZagReader<R, P>where
R: Read,
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>
Source§impl<R, P> Seek for BufferedZigZagReader<R, P>
impl<R, P> Seek for BufferedZigZagReader<R, P>
Source§fn seek(&mut self, position: SeekFrom) -> Result<u64>
fn seek(&mut self, position: SeekFrom) -> Result<u64>
Seeks the wrapped reader and discards buffered bytes after success.
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)Auto Trait Implementations§
impl<R, P> Freeze for BufferedZigZagReader<R, P>where
R: Freeze,
impl<R, P> RefUnwindSafe for BufferedZigZagReader<R, P>where
R: RefUnwindSafe,
impl<R, P> Send for BufferedZigZagReader<R, P>where
R: Send,
impl<R, P> Sync for BufferedZigZagReader<R, P>where
R: Sync,
impl<R, P> Unpin for BufferedZigZagReader<R, P>where
R: Unpin,
impl<R, P> UnsafeUnpin for BufferedZigZagReader<R, P>where
R: UnsafeUnpin,
impl<R, P> UnwindSafe for BufferedZigZagReader<R, P>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<R> BinaryReadExt for R
impl<R> BinaryReadExt for R
Source§fn read_u16(&mut self, byte_order: ByteOrder) -> Result<u16>
fn read_u16(&mut self, byte_order: ByteOrder) -> Result<u16>
Source§fn read_u16_be(&mut self) -> Result<u16>
fn read_u16_be(&mut self) -> Result<u16>
Source§fn read_u16_le(&mut self) -> Result<u16>
fn read_u16_le(&mut self) -> Result<u16>
Source§fn read_u32(&mut self, byte_order: ByteOrder) -> Result<u32>
fn read_u32(&mut self, byte_order: ByteOrder) -> Result<u32>
Source§fn read_u32_be(&mut self) -> Result<u32>
fn read_u32_be(&mut self) -> Result<u32>
Source§fn read_u32_le(&mut self) -> Result<u32>
fn read_u32_le(&mut self) -> Result<u32>
Source§fn read_u64(&mut self, byte_order: ByteOrder) -> Result<u64>
fn read_u64(&mut self, byte_order: ByteOrder) -> Result<u64>
Source§fn read_u64_be(&mut self) -> Result<u64>
fn read_u64_be(&mut self) -> Result<u64>
Source§fn read_u64_le(&mut self) -> Result<u64>
fn read_u64_le(&mut self) -> Result<u64>
Source§fn read_u128(&mut self, byte_order: ByteOrder) -> Result<u128>
fn read_u128(&mut self, byte_order: ByteOrder) -> Result<u128>
Source§fn read_u128_be(&mut self) -> Result<u128>
fn read_u128_be(&mut self) -> Result<u128>
Source§fn read_u128_le(&mut self) -> Result<u128>
fn read_u128_le(&mut self) -> Result<u128>
Source§fn read_i16(&mut self, byte_order: ByteOrder) -> Result<i16>
fn read_i16(&mut self, byte_order: ByteOrder) -> Result<i16>
Source§fn read_i16_be(&mut self) -> Result<i16>
fn read_i16_be(&mut self) -> Result<i16>
Source§fn read_i16_le(&mut self) -> Result<i16>
fn read_i16_le(&mut self) -> Result<i16>
Source§fn read_i32(&mut self, byte_order: ByteOrder) -> Result<i32>
fn read_i32(&mut self, byte_order: ByteOrder) -> Result<i32>
Source§fn read_i32_be(&mut self) -> Result<i32>
fn read_i32_be(&mut self) -> Result<i32>
Source§fn read_i32_le(&mut self) -> Result<i32>
fn read_i32_le(&mut self) -> Result<i32>
Source§fn read_i64(&mut self, byte_order: ByteOrder) -> Result<i64>
fn read_i64(&mut self, byte_order: ByteOrder) -> Result<i64>
Source§fn read_i64_be(&mut self) -> Result<i64>
fn read_i64_be(&mut self) -> Result<i64>
Source§fn read_i64_le(&mut self) -> Result<i64>
fn read_i64_le(&mut self) -> Result<i64>
Source§fn read_i128(&mut self, byte_order: ByteOrder) -> Result<i128>
fn read_i128(&mut self, byte_order: ByteOrder) -> Result<i128>
Source§fn read_i128_be(&mut self) -> Result<i128>
fn read_i128_be(&mut self) -> Result<i128>
Source§fn read_i128_le(&mut self) -> Result<i128>
fn read_i128_le(&mut self) -> Result<i128>
Source§fn read_f32(&mut self, byte_order: ByteOrder) -> Result<f32>
fn read_f32(&mut self, byte_order: ByteOrder) -> Result<f32>
Source§fn read_f32_be(&mut self) -> Result<f32>
fn read_f32_be(&mut self) -> Result<f32>
Source§fn read_f32_le(&mut self) -> Result<f32>
fn read_f32_le(&mut self) -> Result<f32>
Source§fn read_f64(&mut self, byte_order: ByteOrder) -> Result<f64>
fn read_f64(&mut self, byte_order: ByteOrder) -> Result<f64>
Source§fn read_f64_be(&mut self) -> Result<f64>
fn read_f64_be(&mut self) -> Result<f64>
Source§fn read_f64_le(&mut self) -> Result<f64>
fn read_f64_le(&mut self) -> Result<f64>
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
Source§impl<R> Leb128ReadExt for R
impl<R> Leb128ReadExt for R
Source§fn read_uleb_u8(&mut self) -> Result<u8>
fn read_uleb_u8(&mut self) -> Result<u8>
u8.Source§fn read_uleb_u8_strict(&mut self) -> Result<u8>
fn read_uleb_u8_strict(&mut self) -> Result<u8>
u8.Source§fn read_uleb_u16(&mut self) -> Result<u16>
fn read_uleb_u16(&mut self) -> Result<u16>
u16.Source§fn read_uleb_u16_strict(&mut self) -> Result<u16>
fn read_uleb_u16_strict(&mut self) -> Result<u16>
u16.Source§fn read_uleb_u32(&mut self) -> Result<u32>
fn read_uleb_u32(&mut self) -> Result<u32>
u32.Source§fn read_uleb_u32_strict(&mut self) -> Result<u32>
fn read_uleb_u32_strict(&mut self) -> Result<u32>
u32.Source§fn read_uleb_u64(&mut self) -> Result<u64>
fn read_uleb_u64(&mut self) -> Result<u64>
u64.Source§fn read_uleb_u64_strict(&mut self) -> Result<u64>
fn read_uleb_u64_strict(&mut self) -> Result<u64>
u64.Source§fn read_uleb_u128(&mut self) -> Result<u128>
fn read_uleb_u128(&mut self) -> Result<u128>
u128.Source§fn read_uleb_u128_strict(&mut self) -> Result<u128>
fn read_uleb_u128_strict(&mut self) -> Result<u128>
u128.Source§fn read_uleb_usize(&mut self) -> Result<usize>
fn read_uleb_usize(&mut self) -> Result<usize>
usize.Source§fn read_uleb_usize_strict(&mut self) -> Result<usize>
fn read_uleb_usize_strict(&mut self) -> Result<usize>
usize.Source§fn read_sleb_i8(&mut self) -> Result<i8>
fn read_sleb_i8(&mut self) -> Result<i8>
i8.Source§fn read_sleb_i8_strict(&mut self) -> Result<i8>
fn read_sleb_i8_strict(&mut self) -> Result<i8>
i8.Source§fn read_sleb_i16(&mut self) -> Result<i16>
fn read_sleb_i16(&mut self) -> Result<i16>
i16.Source§fn read_sleb_i16_strict(&mut self) -> Result<i16>
fn read_sleb_i16_strict(&mut self) -> Result<i16>
i16.Source§fn read_sleb_i32(&mut self) -> Result<i32>
fn read_sleb_i32(&mut self) -> Result<i32>
i32.Source§fn read_sleb_i32_strict(&mut self) -> Result<i32>
fn read_sleb_i32_strict(&mut self) -> Result<i32>
i32.Source§fn read_sleb_i64(&mut self) -> Result<i64>
fn read_sleb_i64(&mut self) -> Result<i64>
i64.Source§fn read_sleb_i64_strict(&mut self) -> Result<i64>
fn read_sleb_i64_strict(&mut self) -> Result<i64>
i64.Source§fn read_sleb_i128(&mut self) -> Result<i128>
fn read_sleb_i128(&mut self) -> Result<i128>
i128.Source§fn read_sleb_i128_strict(&mut self) -> Result<i128>
fn read_sleb_i128_strict(&mut self) -> Result<i128>
i128.Source§fn read_sleb_isize(&mut self) -> Result<isize>
fn read_sleb_isize(&mut self) -> Result<isize>
isize.Source§fn read_sleb_isize_strict(&mut self) -> Result<isize>
fn read_sleb_isize_strict(&mut self) -> Result<isize>
isize.Source§impl<T> ReadExt for T
impl<T> ReadExt for T
Source§unsafe fn read_unchecked(
&mut self,
buffer: &mut [u8],
start_index: usize,
count: usize,
) -> Result<usize, Error>
unsafe fn read_unchecked( &mut self, buffer: &mut [u8], start_index: usize, count: usize, ) -> Result<usize, Error>
buffer without checking the range bounds
in release builds. Read moreSource§unsafe fn read_exact_or_eof_unchecked(
&mut self,
buffer: &mut [u8],
start_index: usize,
count: usize,
) -> Result<usize, Error>
unsafe fn read_exact_or_eof_unchecked( &mut self, buffer: &mut [u8], start_index: usize, count: usize, ) -> Result<usize, Error>
buffer until that range is full or EOF is
reached, without checking the range bounds in release builds. Read moreSource§unsafe fn read_exact_unchecked(
&mut self,
buffer: &mut [u8],
start_index: usize,
count: usize,
) -> Result<(), Error>
unsafe fn read_exact_unchecked( &mut self, buffer: &mut [u8], start_index: usize, count: usize, ) -> Result<(), Error>
count bytes into a range of buffer without checking
the range bounds in release builds. Read moreSource§fn read_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize, Error>
fn read_exact_or_eof(&mut self, buffer: &mut [u8]) -> Result<usize, Error>
buffer is full or EOF is reached. Read moreSource§fn read_exact_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
fn read_exact_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
N bytes into a stack-allocated array. Read moreSource§fn read_exact_vec_limited(
&mut self,
len: usize,
max_len: usize,
) -> Result<Vec<u8>, Error>
fn read_exact_vec_limited( &mut self, len: usize, max_len: usize, ) -> Result<Vec<u8>, Error>
len bytes into a new vector after checking a limit. Read moreSource§fn read_exact_vec_limited_into(
&mut self,
output: &mut Vec<u8>,
len: usize,
max_len: usize,
) -> Result<(), Error>
fn read_exact_vec_limited_into( &mut self, output: &mut Vec<u8>, len: usize, max_len: usize, ) -> Result<(), Error>
Source§fn discard_exact_or_eof(&mut self, bytes: u64) -> Result<u64, Error>
fn discard_exact_or_eof(&mut self, bytes: u64) -> Result<u64, Error>
bytes bytes from this reader. Read moreSource§fn copy_to(&mut self, writer: &mut dyn Write) -> Result<u64, Error>
fn copy_to(&mut self, writer: &mut dyn Write) -> Result<u64, Error>
writer. Read moreSource§fn copy_to_at_most(
&mut self,
writer: &mut dyn Write,
max_bytes: u64,
) -> Result<u64, Error>
fn copy_to_at_most( &mut self, writer: &mut dyn Write, max_bytes: u64, ) -> Result<u64, Error>
Source§fn copy_to_end_limited(
&mut self,
writer: &mut dyn Write,
max_bytes: u64,
) -> Result<u64, Error>
fn copy_to_end_limited( &mut self, writer: &mut dyn Write, max_bytes: u64, ) -> Result<u64, Error>
max_bytes. Read moreSource§fn read_to_end_limited(&mut self, max_len: usize) -> Result<Vec<u8>, Error>
fn read_to_end_limited(&mut self, max_len: usize) -> Result<Vec<u8>, Error>
Source§fn read_to_end_limited_into(
&mut self,
output: &mut Vec<u8>,
max_len: usize,
) -> Result<usize, Error>
fn read_to_end_limited_into( &mut self, output: &mut Vec<u8>, max_len: usize, ) -> Result<usize, Error>
output with a maximum accepted length. Read moreSource§impl<T> ReadSeekExt for T
impl<T> ReadSeekExt for T
Source§impl<T> StringReadExt for T
impl<T> StringReadExt for T
Source§fn read_utf8_payload(
&mut self,
len: usize,
max_len: usize,
) -> Result<String, Error>
fn read_utf8_payload( &mut self, len: usize, max_len: usize, ) -> Result<String, Error>
Source§fn read_utf8_string_uleb(&mut self, max_len: usize) -> Result<String, Error>
fn read_utf8_string_uleb(&mut self, max_len: usize) -> Result<String, Error>
Source§fn read_utf8_string_uleb_strict(
&mut self,
max_len: usize,
) -> Result<String, Error>
fn read_utf8_string_uleb_strict( &mut self, max_len: usize, ) -> Result<String, Error>
Source§fn read_utf8_string_u16(
&mut self,
byte_order: ByteOrder,
max_len: usize,
) -> Result<String, Error>
fn read_utf8_string_u16( &mut self, byte_order: ByteOrder, max_len: usize, ) -> Result<String, Error>
u16 byte-length prefix. Read moreSource§fn read_utf8_string_u16_be(&mut self, max_len: usize) -> Result<String, Error>
fn read_utf8_string_u16_be(&mut self, max_len: usize) -> Result<String, Error>
u16 byte-length prefix. Read moreSource§fn read_utf8_string_u16_le(&mut self, max_len: usize) -> Result<String, Error>
fn read_utf8_string_u16_le(&mut self, max_len: usize) -> Result<String, Error>
u16 byte-length prefix. Read moreSource§fn read_utf8_string_u32(
&mut self,
byte_order: ByteOrder,
max_len: usize,
) -> Result<String, Error>
fn read_utf8_string_u32( &mut self, byte_order: ByteOrder, max_len: usize, ) -> Result<String, Error>
u32 byte-length prefix. Read moreSource§impl<R> ZigZagReadExt for R
impl<R> ZigZagReadExt for R
Source§fn read_zig_zag_i8(&mut self) -> Result<i8>
fn read_zig_zag_i8(&mut self) -> Result<i8>
i8.Source§fn read_zig_zag_i8_strict(&mut self) -> Result<i8>
fn read_zig_zag_i8_strict(&mut self) -> Result<i8>
i8.Source§fn read_zig_zag_i16(&mut self) -> Result<i16>
fn read_zig_zag_i16(&mut self) -> Result<i16>
i16.Source§fn read_zig_zag_i16_strict(&mut self) -> Result<i16>
fn read_zig_zag_i16_strict(&mut self) -> Result<i16>
i16.Source§fn read_zig_zag_i32(&mut self) -> Result<i32>
fn read_zig_zag_i32(&mut self) -> Result<i32>
i32.Source§fn read_zig_zag_i32_strict(&mut self) -> Result<i32>
fn read_zig_zag_i32_strict(&mut self) -> Result<i32>
i32.Source§fn read_zig_zag_i64(&mut self) -> Result<i64>
fn read_zig_zag_i64(&mut self) -> Result<i64>
i64.Source§fn read_zig_zag_i64_strict(&mut self) -> Result<i64>
fn read_zig_zag_i64_strict(&mut self) -> Result<i64>
i64.Source§fn read_zig_zag_i128(&mut self) -> Result<i128>
fn read_zig_zag_i128(&mut self) -> Result<i128>
i128.Source§fn read_zig_zag_i128_strict(&mut self) -> Result<i128>
fn read_zig_zag_i128_strict(&mut self) -> Result<i128>
i128.Source§fn read_zig_zag_isize(&mut self) -> Result<isize>
fn read_zig_zag_isize(&mut self) -> Result<isize>
isize.Source§fn read_zig_zag_isize_strict(&mut self) -> Result<isize>
fn read_zig_zag_isize_strict(&mut self) -> Result<isize>
isize.