ZCursor

Struct ZCursor 

Source
pub struct ZCursor<T: AsRef<[u8]>> { /* private fields */ }
Expand description

Wraps an in memory buffer providing it with a Seek method but works in no_std environments

std::io::Cursor is available in std environments, but we also need support for no_std environments so this serves as a drop in replacement

Implementations§

Source§

impl<T: AsRef<[u8]>> ZCursor<T>

Source

pub fn new(buffer: T) -> ZCursor<T>

Source§

impl<T: AsRef<[u8]>> ZCursor<T>

Source

pub fn skip(&mut self, num: usize)

Move forward num bytes from the current position.

It doesn’t check that position overflowed, new position may point past the internal buffer, all subsequent reads will either return an error or zero depending on the method called

Source

pub fn rewind(&mut self, num: usize)

Move back num bytes from the current position

This saturates at zero, it can never be negative or wraparound when the value becomes too small

Trait Implementations§

Source§

impl<T: AsRef<[u8]>> From<T> for ZCursor<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<T: AsRef<[u8]>> ZByteReaderTrait for ZCursor<T>

Source§

fn read_byte_no_error(&mut self) -> u8

Read a single byte from the decoder and return 0 if we can’t read the byte, e.g because of EOF Read more
Source§

fn read_exact_bytes(&mut self, buf: &mut [u8]) -> Result<(), ZByteIoError>

Read exact bytes required to fill buf or return an error if that isn’t possible Read more
Source§

fn read_const_bytes<const N: usize>( &mut self, buf: &mut [u8; N], ) -> Result<(), ZByteIoError>

Read exact bytes required to fill buf or return an error if that isn’t possible Read more
Source§

fn read_const_bytes_no_error<const N: usize>(&mut self, buf: &mut [u8; N])

Read exact bytes required to fill buf or ignore buf entirely if you can’t fill it due to an error like the inability to fill the buffer completely Read more
Source§

fn read_bytes(&mut self, buf: &mut [u8]) -> Result<usize, ZByteIoError>

Read bytes into buf returning how many bytes you have read or an error if one occurred Read more
Source§

fn peek_bytes(&mut self, buf: &mut [u8]) -> Result<usize, ZByteIoError>

Reads data into provided buffer but does not advance read position.
Source§

fn peek_exact_bytes(&mut self, buf: &mut [u8]) -> Result<(), ZByteIoError>

Source§

fn z_seek(&mut self, from: ZSeekFrom) -> Result<u64, ZByteIoError>

Seek into a new position from the buffer Read more
Source§

fn is_eof(&mut self) -> Result<bool, ZByteIoError>

Report whether we are at the end of a stream. Read more
Source§

fn z_position(&mut self) -> Result<u64, ZByteIoError>

Return the current position of the inner cursor. Read more
Source§

fn read_remaining(&mut self, sink: &mut Vec<u8>) -> Result<usize, ZByteIoError>

Read all bytes remaining in this input to sink until we hit eof Read more

Auto Trait Implementations§

§

impl<T> Freeze for ZCursor<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ZCursor<T>
where T: RefUnwindSafe,

§

impl<T> Send for ZCursor<T>
where T: Send,

§

impl<T> Sync for ZCursor<T>
where T: Sync,

§

impl<T> Unpin for ZCursor<T>
where T: Unpin,

§

impl<T> UnwindSafe for ZCursor<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.