Properties

Struct Properties 

Source
pub struct Properties { /* private fields */ }
Expand description

Container for MQTT v5.0 properties

Implementations§

Source§

impl Properties

Source

pub fn new() -> Self

Creates a new empty properties container

Source

pub fn add(&mut self, id: PropertyId, value: PropertyValue) -> Result<()>

Adds a property value

§Errors

Returns an error if:

  • The value type doesn’t match the property’s expected type
  • The property doesn’t allow multiple values and already exists
§Errors

Returns an error if the operation fails

Source

pub fn get(&self, id: PropertyId) -> Option<&PropertyValue>

Gets a single property value

Source

pub fn get_all(&self, id: PropertyId) -> Option<&[PropertyValue]>

Gets all values for a property (for properties that allow multiple values)

Source

pub fn contains(&self, id: PropertyId) -> bool

Checks if a property is present

Source

pub fn len(&self) -> usize

Returns the number of properties (counting multi-value properties as one)

Source

pub fn is_empty(&self) -> bool

Checks if there are no properties

Source

pub fn iter(&self) -> impl Iterator<Item = (PropertyId, &PropertyValue)> + '_

Iterates over all properties and their values

Source

pub fn encode<B: BufMut>(&self, buf: &mut B) -> Result<()>

Encodes all properties to the buffer

§Errors

Returns an error if encoding fails

§Errors

Returns an error if the operation fails

Source

pub fn decode<B: Buf>(buf: &mut B) -> Result<Self>

Decodes properties from the buffer

§Errors

Returns an error if:

  • Decoding fails
  • Invalid property ID
  • Type mismatch
  • Duplicate property that doesn’t allow multiples
§Errors

Returns an error if the operation fails

Source

pub fn encoded_len(&self) -> usize

Calculates the encoded length of all properties (including length prefix)

Source

pub fn set_payload_format_indicator(&mut self, is_utf8: bool)

Sets the payload format indicator (0 = unspecified bytes, 1 = UTF-8)

Source

pub fn set_message_expiry_interval(&mut self, seconds: u32)

Sets the message expiry interval in seconds

Source

pub fn get_message_expiry_interval(&self) -> Option<u32>

Gets the message expiry interval in seconds

Source

pub fn set_topic_alias(&mut self, alias: u16)

Sets the topic alias

Source

pub fn get_topic_alias(&self) -> Option<u16>

Gets the topic alias

Source

pub fn set_response_topic(&mut self, topic: String)

Sets the response topic

Source

pub fn set_correlation_data(&mut self, data: Bytes)

Sets the correlation data

Source

pub fn add_user_property(&mut self, key: String, value: String)

Adds a user property (can be called multiple times)

Source

pub fn set_subscription_identifier(&mut self, id: u32)

Sets the subscription identifier

Source

pub fn get_subscription_identifier(&self) -> Option<u32>

Source

pub fn set_session_expiry_interval(&mut self, seconds: u32)

Sets the session expiry interval

Source

pub fn get_session_expiry_interval(&self) -> Option<u32>

Gets the session expiry interval

Source

pub fn set_assigned_client_identifier(&mut self, id: String)

Sets the assigned client identifier

Source

pub fn set_server_keep_alive(&mut self, seconds: u16)

Sets the server keep alive

Source

pub fn set_authentication_method(&mut self, method: String)

Sets the authentication method

Source

pub fn set_authentication_data(&mut self, data: Bytes)

Sets the authentication data

Source

pub fn get_authentication_method(&self) -> Option<&String>

Source

pub fn get_authentication_data(&self) -> Option<&[u8]>

Source

pub fn set_request_problem_information(&mut self, request: bool)

Sets request problem information

Source

pub fn get_request_problem_information(&self) -> Option<bool>

Gets request problem information

Source

pub fn set_will_delay_interval(&mut self, seconds: u32)

Sets the will delay interval

Source

pub fn set_request_response_information(&mut self, request: bool)

Sets request response information

Source

pub fn get_request_response_information(&self) -> Option<bool>

Gets request response information

Source

pub fn set_response_information(&mut self, info: String)

Sets the response information

Source

pub fn set_server_reference(&mut self, reference: String)

Sets the server reference

Source

pub fn set_reason_string(&mut self, reason: String)

Sets the reason string

Source

pub fn set_receive_maximum(&mut self, max: u16)

Sets the receive maximum

Source

pub fn set_topic_alias_maximum(&mut self, max: u16)

Sets the topic alias maximum

Source

pub fn get_topic_alias_maximum(&self) -> Option<u16>

Gets the topic alias maximum

Source

pub fn set_maximum_qos(&mut self, qos: u8)

Sets the maximum QoS

Source

pub fn set_retain_available(&mut self, available: bool)

Sets retain available

Source

pub fn set_maximum_packet_size(&mut self, size: u32)

Sets the maximum packet size

Source

pub fn set_wildcard_subscription_available(&mut self, available: bool)

Sets wildcard subscription available

Source

pub fn set_subscription_identifier_available(&mut self, available: bool)

Sets subscription identifier available

Source

pub fn set_shared_subscription_available(&mut self, available: bool)

Sets shared subscription available

Source

pub fn get_maximum_qos(&self) -> Option<u8>

Gets the maximum QoS

Source

pub fn set_content_type(&mut self, content_type: String)

Sets the content type

Trait Implementations§

Source§

impl Clone for Properties

Source§

fn clone(&self) -> Properties

Returns a duplicate of the value. Read more
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 From<Properties> for MessageProperties

Source§

fn from(props: Properties) -> Self

Converts to this type from the input type.
Source§

impl From<PublishProperties> for Properties

Source§

fn from(props: PublishProperties) -> Self

Converts to this type from the input type.
Source§

impl From<WillProperties> for Properties

Source§

fn from(will_props: WillProperties) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Properties

Source§

fn eq(&self, other: &Properties) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Properties

Source§

impl StructuralPartialEq for Properties

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

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 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more