pub struct MqttOptions { /* private fields */ }

Implementations§

source§

impl MqttOptions

source

pub fn new<S: Into<Arc<String>>, T: Into<String>>( id: S, host: T, port: u16 ) -> Result<MqttOptions>

source

pub fn auto_reconnect(self) -> Self

设置为自动重连,会默认设置clean_session=false

source

pub fn set_tls(self, config: TlsConfig) -> Self

source

pub fn broker_address(&self) -> (String, u16)

Broker address

source

pub fn set_last_will(&mut self, will: LastWill) -> &mut Self

source

pub fn last_will(&self) -> Option<LastWill>

source

pub fn set_keep_alive(self, duration: u16) -> Self

Set number of seconds after which client should ping the broker if there is no other data exchange

source

pub fn keep_alive(&self) -> u16

Keep alive time

source

pub fn client_id(&self) -> Arc<String>

Client identifier

source

pub fn set_max_packet_size( &mut self, incoming: usize, outgoing: usize ) -> &mut Self

Set packet size limit for outgoing an incoming packets

source

pub fn max_packet_size(&self) -> usize

Maximum packet size

source

pub fn set_clean_session(&mut self, clean_session: bool) -> &mut Self

clean_session = true removes all the state from queues & instructs the broker to clean all the client state when client disconnects.

When set false, broker will hold the client state and performs pending operations on the client when reconnection with same client_id happens. Local queue state is also held to retransmit packets after reconnection.

source

pub fn clean_session(&self) -> bool

Clean session

source

pub fn set_credentials<U: Into<Arc<String>>, P1: Into<Arc<String>>>( &mut self, username: U, password: P1 ) -> &mut Self

Username and password

source

pub fn credentials(&self) -> Option<(Arc<String>, Arc<String>)>

Security options

source

pub async fn connect_to_v4(self) -> Client

source

pub async fn connect_to_v5(self) -> Client

Trait Implementations§

source§

impl Clone for MqttOptions

source§

fn clone(&self) -> MqttOptions

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
source§

impl Debug for MqttOptions

source§

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

Formats the value using the given formatter. Read more

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.