Struct rust_mqtt::packet::v5::connect_packet::ConnectPacket
source · pub struct ConnectPacket<'a, const MAX_PROPERTIES: usize, const MAX_WILL_PROPERTIES: usize> {Show 16 fields
pub fixed_header: u8,
pub remain_len: u32,
pub protocol_name_len: u16,
pub protocol_name: u32,
pub protocol_version: u8,
pub connect_flags: u8,
pub keep_alive: u16,
pub property_len: u32,
pub properties: Vec<Property<'a>, MAX_PROPERTIES>,
pub client_id: EncodedString<'a>,
pub will_property_len: u32,
pub will_properties: Vec<Property<'a>, MAX_WILL_PROPERTIES>,
pub will_topic: EncodedString<'a>,
pub will_payload: BinaryData<'a>,
pub username: EncodedString<'a>,
pub password: BinaryData<'a>,
}
Fields§
§fixed_header: u8
§remain_len: u32
§protocol_name_len: u16
§protocol_name: u32
§protocol_version: u8
§connect_flags: u8
§keep_alive: u16
§property_len: u32
§properties: Vec<Property<'a>, MAX_PROPERTIES>
§client_id: EncodedString<'a>
§will_property_len: u32
§will_properties: Vec<Property<'a>, MAX_WILL_PROPERTIES>
§will_topic: EncodedString<'a>
§will_payload: BinaryData<'a>
§username: EncodedString<'a>
§password: BinaryData<'a>
Implementations§
source§impl<'a, const MAX_PROPERTIES: usize, const MAX_WILL_PROPERTIES: usize> ConnectPacket<'a, MAX_PROPERTIES, MAX_WILL_PROPERTIES>
impl<'a, const MAX_PROPERTIES: usize, const MAX_WILL_PROPERTIES: usize> ConnectPacket<'a, MAX_PROPERTIES, MAX_WILL_PROPERTIES>
pub fn clean() -> Self
pub fn add_packet_type(&mut self, new_packet_type: PacketType)
pub fn add_username(&mut self, username: &EncodedString<'a>)
pub fn add_password(&mut self, password: &BinaryData<'a>)
pub fn add_will(
&mut self,
topic: &EncodedString<'a>,
payload: &BinaryData<'a>,
retain: bool
)
pub fn add_client_id(&mut self, id: &EncodedString<'a>)
Trait Implementations§
source§impl<'a, const MAX_PROPERTIES: usize, const MAX_WILL_PROPERTIES: usize> Packet<'a> for ConnectPacket<'a, MAX_PROPERTIES, MAX_WILL_PROPERTIES>
impl<'a, const MAX_PROPERTIES: usize, const MAX_WILL_PROPERTIES: usize> Packet<'a> for ConnectPacket<'a, MAX_PROPERTIES, MAX_WILL_PROPERTIES>
fn new() -> Self
source§fn encode(
&mut self,
buffer: &mut [u8],
buffer_len: usize
) -> Result<usize, BufferError>
fn encode(
&mut self,
buffer: &mut [u8],
buffer_len: usize
) -> Result<usize, BufferError>
Method encode provide way how to transfer Packet struct into Byte array (buffer)
source§fn decode(
&mut self,
_buff_reader: &mut BuffReader<'a>
) -> Result<(), BufferError>
fn decode(
&mut self,
_buff_reader: &mut BuffReader<'a>
) -> Result<(), BufferError>
Decode method is opposite of encode - decoding Byte array and mapping it into corresponding Packet struct
source§fn set_property_len(&mut self, value: u32)
fn set_property_len(&mut self, value: u32)
Setter method for packet properties len - not all Packet types support this
source§fn get_property_len(&mut self) -> u32
fn get_property_len(&mut self) -> u32
Setter method for packet properties len - not all Packet types support this
source§fn push_to_properties(&mut self, property: Property<'a>)
fn push_to_properties(&mut self, property: Property<'a>)
Method enables pushing new property into packet properties
source§fn property_allowed(&mut self, property: &Property<'a>) -> bool
fn property_allowed(&mut self, property: &Property<'a>) -> bool
Returns if property is allowed for packet
source§fn set_fixed_header(&mut self, header: u8)
fn set_fixed_header(&mut self, header: u8)
Setter for packet fixed header
source§fn set_remaining_len(&mut self, remaining_len: u32)
fn set_remaining_len(&mut self, remaining_len: u32)
Setter for remaining len
source§fn add_properties<const MAX_PROPERTIES: usize>(
&mut self,
properties: &Vec<Property<'a>, MAX_PROPERTIES>
) -> u32
fn add_properties<const MAX_PROPERTIES: usize>(
&mut self,
properties: &Vec<Property<'a>, MAX_PROPERTIES>
) -> u32
Method enables adding properties from client config - each packet decides if property can be used with that or not
source§fn decode_properties(
&mut self,
buff_reader: &mut BuffReader<'a>
) -> Result<(), BufferError>
fn decode_properties(
&mut self,
buff_reader: &mut BuffReader<'a>
) -> Result<(), BufferError>
Method is decoding Byte array pointing to properties into heapless Vec
in packet. If decoding goes wrong method is returning Error
source§fn decode_fixed_header(
&mut self,
buff_reader: &mut BuffReader<'_>
) -> Result<PacketType, BufferError>
fn decode_fixed_header(
&mut self,
buff_reader: &mut BuffReader<'_>
) -> Result<PacketType, BufferError>
Method is decoding packet header into fixed header part and remaining length