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>
impl<'a> BuffWriter<'a>
pub fn new(buffer: &'a mut [u8], buff_len: usize) -> Self
Sourcepub fn get_n_byte(&mut self, n: usize) -> u8
pub fn get_n_byte(&mut self, n: usize) -> u8
Returns n-th Byte from the buffer to which is currently written.
Sourcepub fn get_rem_len(&mut self) -> Result<VariableByteInteger, RemLenError>
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.
Sourcepub fn insert_ref(
&mut self,
len: usize,
array: &[u8],
) -> Result<(), BufferError>
pub fn insert_ref( &mut self, len: usize, array: &[u8], ) -> Result<(), BufferError>
Writes (part of) an array to the buffer.
Sourcepub fn write_u8(&mut self, byte: u8) -> Result<(), BufferError>
pub fn write_u8(&mut self, byte: u8) -> Result<(), BufferError>
Writes a single Byte to the buffer.
Sourcepub fn write_u16(&mut self, two_bytes: u16) -> Result<(), BufferError>
pub fn write_u16(&mut self, two_bytes: u16) -> Result<(), BufferError>
Writes the two Byte value to the buffer.
Sourcepub fn write_u32(&mut self, four_bytes: u32) -> Result<(), BufferError>
pub fn write_u32(&mut self, four_bytes: u32) -> Result<(), BufferError>
Writes the four Byte value to the buffer.
Sourcepub fn write_string_ref(
&mut self,
str: &EncodedString<'a>,
) -> Result<(), BufferError>
pub fn write_string_ref( &mut self, str: &EncodedString<'a>, ) -> Result<(), BufferError>
Writes the UTF-8 string type to the buffer.
Sourcepub fn write_binary_ref(
&mut self,
bin: &BinaryData<'a>,
) -> Result<(), BufferError>
pub fn write_binary_ref( &mut self, bin: &BinaryData<'a>, ) -> Result<(), BufferError>
Writes BinaryData to the buffer.
Sourcepub fn write_string_pair_ref(
&mut self,
str_pair: &StringPair<'a>,
) -> Result<(), BufferError>
pub fn write_string_pair_ref( &mut self, str_pair: &StringPair<'a>, ) -> Result<(), BufferError>
Writes the string pair to the buffer.
Sourcepub fn write_variable_byte_int(&mut self, int: u32) -> Result<(), BufferError>
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.
Sourcepub fn write_properties<const LEN: usize>(
&mut self,
properties: &Vec<Property<'a>, LEN>,
) -> Result<(), BufferError>
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.
Sourcepub fn write_topic_filters_ref<const MAX: usize>(
&mut self,
sub: bool,
_len: usize,
filters: &Vec<TopicFilter<'a>, MAX>,
) -> Result<(), BufferError>
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.