Struct BuffReader

Source
pub struct BuffReader<'a> {
    pub position: usize,
    /* private fields */
}
Expand description

Buff reader is reading corresponding types from buffer (Byte array) and stores current position (later as cursor)

Fields§

§position: usize

Implementations§

Source§

impl<'a> BuffReader<'a>

Source

pub fn increment_position(&mut self, increment: usize)

Source

pub fn new(buffer: &'a [u8], buff_len: usize) -> Self

Source

pub fn read_variable_byte_int(&mut self) -> Result<u32, BufferError>

Variable byte integer can be 1-4 Bytes long. Buffer reader takes all 4 Bytes at first and than check what is true length of varbyteint and increment cursor by that

Source

pub fn read_u32(&mut self) -> Result<u32, BufferError>

Reading u32 from buffer as Big endian

Source

pub fn read_u16(&mut self) -> Result<u16, BufferError>

Reading u16 from buffer as Big endinan

Source

pub fn read_u8(&mut self) -> Result<u8, BufferError>

Reading one byte from buffer as Big endian

Source

pub fn read_string(&mut self) -> Result<EncodedString<'a>, BufferError>

Reading UTF-8 encoded string from buffer

Source

pub fn read_binary(&mut self) -> Result<BinaryData<'a>, BufferError>

Read Binary data from buffer

Source

pub fn read_string_pair(&mut self) -> Result<StringPair<'a>, BufferError>

Read string pair from buffer

Source

pub fn read_message(&mut self, total_len: usize) -> &'a [u8]

Read payload message from buffer

Source

pub fn peek_u8(&self) -> Result<u8, BufferError>

Peeking (without incremental internal pointer) one byte from buffer as Big endian

Auto Trait Implementations§

§

impl<'a> Freeze for BuffReader<'a>

§

impl<'a> RefUnwindSafe for BuffReader<'a>

§

impl<'a> Send for BuffReader<'a>

§

impl<'a> Sync for BuffReader<'a>

§

impl<'a> Unpin for BuffReader<'a>

§

impl<'a> UnwindSafe for BuffReader<'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.