Struct minetest_protocol::wire::deser::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>
impl<'a> Deserializer<'a>
pub fn new(context: ProtocolContext, data: &'a [u8]) -> Self
sourcepub fn slice(&mut self, count: usize) -> DeserializeResult<Self>
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
pub fn context(&self) -> ProtocolContext
pub fn direction(&self) -> CommandDirection
pub fn remaining(&self) -> usize
sourcepub fn find(&mut self, b: u8) -> Option<usize>
pub fn find(&mut self, b: u8) -> Option<usize>
Finds the first occurance of the byte ‘b’ from the current position in the stream.
pub fn peek(&mut self, count: usize) -> DeserializeResult<&'a [u8]>
pub fn peek_all(&mut self) -> &'a [u8] ⓘ
pub fn take(&mut self, count: usize) -> DeserializeResult<&'a [u8]>
pub fn take_n<const N: usize>(&mut self) -> DeserializeResult<[u8; N]>
pub fn take_all(&mut self) -> &'a [u8] ⓘ
sourcepub fn peek_line(&mut self) -> DeserializeResult<&'a [u8]>
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.
sourcepub fn take_line(&mut self) -> DeserializeResult<&'a [u8]>
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.
sourcepub fn take_word(&mut self, skip_whitespace: bool) -> &'a [u8] ⓘ
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.
sourcepub fn take_space(&mut self)
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)