Skip to main content

Input

Struct Input 

Source
pub struct Input<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Input<'a>

Source

pub fn new(buf: &'a mut &'a [u8]) -> Self

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn advance(&mut self, len: usize) -> Result<&[u8], FormatError>

Splits the first len bytes from the input, returning them as a slice and updating the input buffer. Returns an error if there are not enough bytes remaining to fulfill the request.

Source

pub fn local_peek_bytes(&self, len: usize) -> Result<&[u8], FormatError>

Similar to advance(), but does not advance the input, only returns a reference to the next len bytes.

Not to be confused with the struct-wide peeking functionality that switches between consuming the buffer and advancing a cursor.

Source

pub fn local_peek_byte(&self, offset: usize) -> Result<u8, FormatError>

Similar to local_peek_bytes(), but returns a single byte.

Not to be confused with the struct-wide peeking functionality that switches between consuming the buffer and advancing a cursor.

Source

pub fn start_peek(&mut self)

Source

pub fn peek_cursor(&self) -> usize

The peek cursor from the view of the current innermost peek.

Source

pub fn end_peek(&mut self) -> bool

End a peek and proceed with normal input processing. This method can only be used after a peek is started. If there was no ongoing peek, the method will panic.

Returns true if the peek pass is over, false if there is still an outer peek being processed.

Auto Trait Implementations§

§

impl<'a> Freeze for Input<'a>

§

impl<'a> RefUnwindSafe for Input<'a>

§

impl<'a> Send for Input<'a>

§

impl<'a> Sync for Input<'a>

§

impl<'a> Unpin for Input<'a>

§

impl<'a> UnsafeUnpin for Input<'a>

§

impl<'a> !UnwindSafe for Input<'a>

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> Same for T

Source§

type Output = T

Should always be Self
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.