Struct Deserializer

Source
pub struct Deserializer<'a> {
    pub context: ProtocolContext,
    pub data: &'a [u8],
}

Fields§

§context: ProtocolContext§data: &'a [u8]

Implementations§

Source§

impl<'a> Deserializer<'a>

Source

pub fn new(context: ProtocolContext, data: &'a [u8]) -> Self

Source

pub fn slice(&mut self, count: usize) -> DeserializeResult<Self>

Take a number of bytes, and return a sub-Deserializer which only operates on those bytes

Source

pub fn context(&self) -> ProtocolContext

Source

pub fn direction(&self) -> CommandDirection

Source

pub fn remaining(&self) -> usize

Source

pub fn find(&mut self, b: u8) -> Option<usize>

Finds the first occurance of the byte ‘b’ from the current position in the stream.

Source

pub fn peek(&mut self, count: usize) -> DeserializeResult<&'a [u8]>

Source

pub fn peek_all(&mut self) -> &'a [u8]

Source

pub fn take(&mut self, count: usize) -> DeserializeResult<&'a [u8]>

Source

pub fn take_n<const N: usize>(&mut self) -> DeserializeResult<[u8; N]>

Source

pub fn take_all(&mut self) -> &'a [u8]

Source

pub fn peek_line(&mut self) -> DeserializeResult<&'a [u8]>

Peek the next line (including ending \n, if present) If the stream is at end, this will be an empty slice.

Source

pub fn take_line(&mut self) -> DeserializeResult<&'a [u8]>

Take the next line (including ending \n, if present) If the stream is at end, this will be an empty slice.

Source

pub fn take_word(&mut self, skip_whitespace: bool) -> &'a [u8]

Take bytes until whitespace or end of stream If skip_whitespace is true, skips initial whitespace first. If skip_whitespace is false, and the next byte is a space, nothing is taken, and the returned will be empty.

Source

pub fn take_space(&mut self)

Take whitespace from the current cursor. Repositioning the cursor at the start of the next word (or end of stream)

Auto Trait Implementations§

§

impl<'a> Freeze for Deserializer<'a>

§

impl<'a> RefUnwindSafe for Deserializer<'a>

§

impl<'a> Send for Deserializer<'a>

§

impl<'a> Sync for Deserializer<'a>

§

impl<'a> Unpin for Deserializer<'a>

§

impl<'a> UnwindSafe for Deserializer<'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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V