pub struct Properties { /* private fields */ }
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.

Implementations§

source§

impl Properties

source

pub fn new() -> Self

Creates a new, empty collection of properties.

source

pub fn from_c_struct(cprops: &MQTTProperties) -> Self

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.

source

pub fn is_empty(&self) -> bool

Determines if the property list has no items in it.

source

pub fn len(&self) -> usize

Gets the number of property items in the collection.

source

pub fn byte_len(&self) -> usize

Gets the number of bytes required for the serialized list on the wire.

source

pub fn clear(&mut self)

Removes all the items from the property list.

source

pub fn push(&mut self, prop: Property) -> Result<()>

Adds a property to the colletion.

source

pub fn push_val<T>(&mut self, code: PropertyCode, val: T) -> Result<()>where T: Any + 'static,

Adds a property to the collection given the property code and value.

source

pub fn push_byte(&mut self, code: PropertyCode, val: u8) -> Result<()>

Adds an single-byte property to the collection.

source

pub fn push_u16(&mut self, code: PropertyCode, val: u16) -> Result<()>

Adds an two-byte integer property to the collection.

source

pub fn push_u32(&mut self, code: PropertyCode, val: u32) -> Result<()>

Adds a four-byte integer property to the collection.

source

pub fn push_int(&mut self, code: PropertyCode, val: i32) -> Result<()>

Adds an integer property to the collection.

This works for any integer type.

source

pub fn push_binary<V>(&mut self, code: PropertyCode, bin: V) -> Result<()>where V: Into<Binary>,

Adds a binary property to the collection

source

pub fn push_string(&mut self, code: PropertyCode, s: &str) -> Result<()>

Adds a string property to the collection

source

pub fn push_string_pair( &mut self, code: PropertyCode, key: &str, val: &str ) -> Result<()>

Adds a string pair property to the collection

source

pub fn get(&self, code: PropertyCode) -> Option<Property>

Gets a property instance

source

pub fn get_at(&self, code: PropertyCode, idx: usize) -> Option<Property>

Gets a property instance when there are possibly multiple values.

source

pub fn iter(&self, code: PropertyCode) -> PropertyIterator<'_>

Gets an iterator for a property instance

source

pub fn get_val_at<T>(&self, code: PropertyCode, idx: usize) -> Option<T>where T: Any + 'static + Send + Default,

Gets a value from the collection when there may be more than one for the code.

source

pub fn get_val<T>(&self, code: PropertyCode) -> Option<T>where T: Any + 'static + Send + Default,

Gets a value from the collection when there may be more than one for the code.

source

pub fn get_int(&self, code: PropertyCode) -> Option<i32>

Gets an integer value of a specific property.

source

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.

source

pub fn get_binary(&self, code: PropertyCode) -> Option<Binary>

Gets a binary value of a specific property.

source

pub fn get_binary_at(&self, code: PropertyCode, idx: usize) -> Option<Binary>

Gets a binary value of a specific value when there may be more than one.

source

pub fn get_string(&self, code: PropertyCode) -> Option<String>

Gets a string value of a specific property.

source

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.

source

pub fn get_string_pair(&self, code: PropertyCode) -> Option<(String, String)>

Gets a string pair for a specific property.

source

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.

source

pub fn user_iter(&self) -> StringPairIterator<'_>

Gets an iterator into the user property string pairs.

source

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§

source§

impl Clone for Properties

source§

fn clone(&self) -> Self

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)

Performs copy-assignment from source. Read more
source§

impl Debug for Properties

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Properties

source§

fn default() -> Properties

Returns the “default value” for a type. Read more
source§

impl Drop for Properties

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Properties

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.