Struct ClientConfig

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

Source

pub fn new(version: MqttVersion, rng: T) -> Self

Source

pub fn add_max_subscribe_qos(&mut self, qos: QualityOfService)

Source

pub fn add_will(&mut self, topic: &'a str, payload: &'a [u8], retain: bool)

Source

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

Source

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

Source

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.

Source

pub fn add_max_packet_size_as_prop(&mut self) -> u32

Method encode the max_packet_size attribute as property to the properties Vec.

Source

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>

Source§

fn clone(&self) -> ClientConfig<'a, MAX_PROPERTIES, T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a, const MAX_PROPERTIES: usize, T> Freeze for ClientConfig<'a, MAX_PROPERTIES, T>
where T: Freeze,

§

impl<'a, const MAX_PROPERTIES: usize, T> RefUnwindSafe for ClientConfig<'a, MAX_PROPERTIES, T>
where T: RefUnwindSafe,

§

impl<'a, const MAX_PROPERTIES: usize, T> Send for ClientConfig<'a, MAX_PROPERTIES, T>
where T: Send,

§

impl<'a, const MAX_PROPERTIES: usize, T> Sync for ClientConfig<'a, MAX_PROPERTIES, T>
where T: Sync,

§

impl<'a, const MAX_PROPERTIES: usize, T> Unpin for ClientConfig<'a, MAX_PROPERTIES, T>
where T: Unpin,

§

impl<'a, const MAX_PROPERTIES: usize, T> UnwindSafe for ClientConfig<'a, MAX_PROPERTIES, T>
where T: UnwindSafe,

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, 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.