Struct Properties
pub struct Properties {
pub(crate) cprops: MQTTProperties,
}Expand description
A collection of MQTT v5 properties.
This is a collection of properties that can be added to outgoing packets or retrieved from incoming packets.
Fields§
§cprops: MQTTPropertiesImplementations§
§impl Properties
impl Properties
pub fn new() -> Properties
pub fn new() -> Properties
Creates a new, empty collection of properties.
pub fn from_c_struct(cprops: &MQTTProperties) -> Properties
pub fn from_c_struct(cprops: &MQTTProperties) -> Properties
Creates a set of properties from an underlying C struct.
This does a deep copy of the properties in the C lib and then keeps the copy.
pub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Gets the number of bytes required for the serialized list on the wire.
pub fn clear(&mut self)
pub fn clear(&mut self)
Removes all the items from the property list.
pub fn push_val<T>(&mut self, code: PropertyCode, val: T) -> Result<(), Error>where
T: Any + 'static,
pub fn push_val<T>(&mut self, code: PropertyCode, val: T) -> Result<(), Error>where
T: Any + 'static,
Adds a property to the collection given the property code and value.
pub fn push_byte(&mut self, code: PropertyCode, val: u8) -> Result<(), Error>
pub fn push_byte(&mut self, code: PropertyCode, val: u8) -> Result<(), Error>
Adds an single-byte property to the collection.
pub fn push_u16(&mut self, code: PropertyCode, val: u16) -> Result<(), Error>
pub fn push_u16(&mut self, code: PropertyCode, val: u16) -> Result<(), Error>
Adds an two-byte integer property to the collection.
pub fn push_u32(&mut self, code: PropertyCode, val: u32) -> Result<(), Error>
pub fn push_u32(&mut self, code: PropertyCode, val: u32) -> Result<(), Error>
Adds a four-byte integer property to the collection.
pub fn push_int(&mut self, code: PropertyCode, val: i32) -> Result<(), Error>
pub fn push_int(&mut self, code: PropertyCode, val: i32) -> Result<(), Error>
Adds an integer property to the collection.
This works for any integer type.
pub fn push_binary<V>(
&mut self,
code: PropertyCode,
bin: V,
) -> Result<(), Error>
pub fn push_binary<V>( &mut self, code: PropertyCode, bin: V, ) -> Result<(), Error>
Adds a binary property to the collection
pub fn push_string(&mut self, code: PropertyCode, s: &str) -> Result<(), Error>
pub fn push_string(&mut self, code: PropertyCode, s: &str) -> Result<(), Error>
Adds a string property to the collection
pub fn push_string_pair(
&mut self,
code: PropertyCode,
key: &str,
val: &str,
) -> Result<(), Error>
pub fn push_string_pair( &mut self, code: PropertyCode, key: &str, val: &str, ) -> Result<(), Error>
Adds a string pair property to the collection
pub fn get(&self, code: PropertyCode) -> Option<Property>
pub fn get(&self, code: PropertyCode) -> Option<Property>
Gets a property instance
pub fn get_at(&self, code: PropertyCode, idx: usize) -> Option<Property>
pub fn get_at(&self, code: PropertyCode, idx: usize) -> Option<Property>
Gets a property instance when there are possibly multiple values.
pub fn iter(&self, code: PropertyCode) -> PropertyIterator<'_> ⓘ
pub fn iter(&self, code: PropertyCode) -> PropertyIterator<'_> ⓘ
Gets an iterator for a property instance
pub fn get_val_at<T>(&self, code: PropertyCode, idx: usize) -> Option<T>
pub fn get_val_at<T>(&self, code: PropertyCode, idx: usize) -> Option<T>
Gets a value from the collection when there may be more than one for the code.
pub fn get_val<T>(&self, code: PropertyCode) -> Option<T>
pub fn get_val<T>(&self, code: PropertyCode) -> Option<T>
Gets a value from the collection when there may be more than one for the code.
pub fn get_int(&self, code: PropertyCode) -> Option<i32>
pub fn get_int(&self, code: PropertyCode) -> Option<i32>
Gets an integer value of a specific property.
pub fn get_int_at(&self, code: PropertyCode, idx: usize) -> Option<i32>
pub fn get_int_at(&self, code: PropertyCode, idx: usize) -> Option<i32>
Gets an integer value of a specific value when there may be more than one.
pub fn get_binary(&self, code: PropertyCode) -> Option<Vec<u8>>
pub fn get_binary(&self, code: PropertyCode) -> Option<Vec<u8>>
Gets a binary value of a specific property.
pub fn get_binary_at(&self, code: PropertyCode, idx: usize) -> Option<Vec<u8>>
pub fn get_binary_at(&self, code: PropertyCode, idx: usize) -> Option<Vec<u8>>
Gets a binary value of a specific value when there may be more than one.
pub fn get_string(&self, code: PropertyCode) -> Option<String>
pub fn get_string(&self, code: PropertyCode) -> Option<String>
Gets a string value of a specific property.
pub fn get_string_at(&self, code: PropertyCode, idx: usize) -> Option<String>
pub fn get_string_at(&self, code: PropertyCode, idx: usize) -> Option<String>
Gets a binary value of a specific value when there may be more than one.
pub fn get_string_pair(&self, code: PropertyCode) -> Option<(String, String)>
pub fn get_string_pair(&self, code: PropertyCode) -> Option<(String, String)>
Gets a string pair for a specific property.
pub fn get_string_pair_at(
&self,
code: PropertyCode,
idx: usize,
) -> Option<(String, String)>
pub fn get_string_pair_at( &self, code: PropertyCode, idx: usize, ) -> Option<(String, String)>
Gets a string pair for a specific property when there may be more than one.
pub fn user_iter(&self) -> StringPairIterator<'_> ⓘ
pub fn user_iter(&self) -> StringPairIterator<'_> ⓘ
Gets an iterator into the user property string pairs.
pub fn find_user_property(&self, key: &str) -> Option<String>
pub fn find_user_property(&self, key: &str) -> Option<String>
Searches for the specified key in the user properties and returns the value if found.
Trait Implementations§
§impl Clone for Properties
impl Clone for Properties
§fn clone(&self) -> Properties
fn clone(&self) -> Properties
Creates a clone of the property. For string any binary properties, this also clones the heap memory so that each property is managing separate allocations.
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more