Struct BuffWriter

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

Buff writer is writing corresponding types to buffer (Byte array) and stores current position (later as cursor)

Fields§

§position: usize

Implementations§

Source§

impl<'a> BuffWriter<'a>

Source

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

Source

pub fn get_n_byte(&mut self, n: usize) -> u8

Returns n-th Byte from the buffer to which is currently written.

Source

pub fn get_rem_len(&mut self) -> Result<VariableByteInteger, RemLenError>

Return the remaining lenght of the packet from the buffer to which is packet written.

Source

pub fn insert_ref( &mut self, len: usize, array: &[u8], ) -> Result<(), BufferError>

Writes (part of) an array to the buffer.

Source

pub fn write_u8(&mut self, byte: u8) -> Result<(), BufferError>

Writes a single Byte to the buffer.

Source

pub fn write_u16(&mut self, two_bytes: u16) -> Result<(), BufferError>

Writes the two Byte value to the buffer.

Source

pub fn write_u32(&mut self, four_bytes: u32) -> Result<(), BufferError>

Writes the four Byte value to the buffer.

Source

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

Writes the UTF-8 string type to the buffer.

Source

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

Writes BinaryData to the buffer.

Source

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

Writes the string pair to the buffer.

Source

pub fn write_variable_byte_int(&mut self, int: u32) -> Result<(), BufferError>

Encodes the u32 value into the VariableByteInteger and this value writes to the buffer.

Source

pub fn write_properties<const LEN: usize>( &mut self, properties: &Vec<Property<'a>, LEN>, ) -> Result<(), BufferError>

Writes all properties from the properties Vec into the buffer.

Source

pub fn write_topic_filters_ref<const MAX: usize>( &mut self, sub: bool, _len: usize, filters: &Vec<TopicFilter<'a>, MAX>, ) -> Result<(), BufferError>

Writes the topic filter Vec to the buffer. If the sub option is set to false, it will not write the sub_options only topic names.

Auto Trait Implementations§

§

impl<'a> Freeze for BuffWriter<'a>

§

impl<'a> RefUnwindSafe for BuffWriter<'a>

§

impl<'a> Send for BuffWriter<'a>

§

impl<'a> Sync for BuffWriter<'a>

§

impl<'a> Unpin for BuffWriter<'a>

§

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