pub struct ClientConfig<'a, const MAX_PROPERTIES: usize, T: RngCore> {Show 15 fields
pub max_subscribe_qos: QualityOfService,
pub keep_alive: u16,
pub username_flag: bool,
pub username: EncodedString<'a>,
pub password_flag: bool,
pub password: BinaryData<'a>,
pub properties: Vec<Property<'a>, MAX_PROPERTIES>,
pub max_packet_size: u32,
pub mqtt_version: MqttVersion,
pub rng: T,
pub will_flag: bool,
pub will_topic: EncodedString<'a>,
pub will_payload: BinaryData<'a>,
pub will_retain: bool,
pub client_id: EncodedString<'a>,
}
Expand description
Client config is main configuration for the MQTTClient
structure.
All of the properties are optional if they are not set they are not gonna
be used. Configuration contains also MQTTv5 properties. Generic constant
MAX_PROPERTIES
sets the length for the properties Vec. User can insert
all the properties and client will automatically use variables that are
usable for the specific packet types. mqtt_version
sets the version
of the MQTT protocol that is gonna be used. Config also expects the rng
implementation. This implementation is used for generating packet identifiers.
There is counting rng implementation in the utils
module that can be used.
Examples of the configurations can be found in the integration tests.
Fields§
§max_subscribe_qos: QualityOfService
§keep_alive: u16
§username_flag: bool
§username: EncodedString<'a>
§password_flag: bool
§password: BinaryData<'a>
§properties: Vec<Property<'a>, MAX_PROPERTIES>
§max_packet_size: u32
§mqtt_version: MqttVersion
§rng: T
§will_flag: bool
§will_topic: EncodedString<'a>
§will_payload: BinaryData<'a>
§will_retain: bool
§client_id: EncodedString<'a>
Implementations§
Source§impl<'a, const MAX_PROPERTIES: usize, T: RngCore> ClientConfig<'a, MAX_PROPERTIES, T>
impl<'a, const MAX_PROPERTIES: usize, T: RngCore> ClientConfig<'a, MAX_PROPERTIES, T>
pub fn new(version: MqttVersion, rng: T) -> Self
pub fn add_max_subscribe_qos(&mut self, qos: QualityOfService)
pub fn add_will(&mut self, topic: &'a str, payload: &'a [u8], retain: bool)
Sourcepub fn add_username(&mut self, username: &'a str)
pub fn add_username(&mut self, username: &'a str)
Method adds the username array and also sets the username flag so client will use it for the authentication
Sourcepub fn add_password(&mut self, password: &'a str)
pub fn add_password(&mut self, password: &'a str)
Method adds the password array and also sets the password flag so client will use it for the authentication
Sourcepub fn add_property(&mut self, prop: Property<'a>)
pub fn add_property(&mut self, prop: Property<'a>)
Method adds the property to the properties Vec if there is still space. Otherwise do nothing.
Sourcepub fn add_max_packet_size_as_prop(&mut self) -> u32
pub fn add_max_packet_size_as_prop(&mut self) -> u32
Method encode the max_packet_size
attribute as property to the properties Vec.
pub fn add_client_id(&mut self, client_id: &'a str)
Trait Implementations§
Source§impl<'a, const MAX_PROPERTIES: usize, T: Clone + RngCore> Clone for ClientConfig<'a, MAX_PROPERTIES, T>
impl<'a, const MAX_PROPERTIES: usize, T: Clone + RngCore> Clone for ClientConfig<'a, MAX_PROPERTIES, T>
Source§fn clone(&self) -> ClientConfig<'a, MAX_PROPERTIES, T>
fn clone(&self) -> ClientConfig<'a, MAX_PROPERTIES, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more