Struct for_mqtt_client::protocol::MqttOptions
source · pub struct MqttOptions { /* private fields */ }Implementations§
source§impl MqttOptions
impl MqttOptions
pub fn new<S: Into<Arc<String>>, T: Into<String>>( id: S, host: T, port: u16 ) -> Result<MqttOptions>
sourcepub fn auto_reconnect(self) -> Self
pub fn auto_reconnect(self) -> Self
设置为自动重连,会默认设置clean_session=false
pub fn set_tls(self, config: TlsConfig) -> Self
sourcepub fn broker_address(&self) -> (String, u16)
pub fn broker_address(&self) -> (String, u16)
Broker address
pub fn set_last_will(&mut self, will: LastWill) -> &mut Self
pub fn last_will(&self) -> Option<LastWill>
sourcepub fn set_keep_alive(self, duration: u16) -> Self
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
sourcepub fn keep_alive(&self) -> u16
pub fn keep_alive(&self) -> u16
Keep alive time
sourcepub fn set_max_packet_size(
&mut self,
incoming: usize,
outgoing: usize
) -> &mut Self
pub fn set_max_packet_size( &mut self, incoming: usize, outgoing: usize ) -> &mut Self
Set packet size limit for outgoing an incoming packets
sourcepub fn max_packet_size(&self) -> usize
pub fn max_packet_size(&self) -> usize
Maximum packet size
sourcepub fn set_clean_session(&mut self, clean_session: bool) -> &mut Self
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.
sourcepub fn clean_session(&self) -> bool
pub fn clean_session(&self) -> bool
Clean session
sourcepub fn set_credentials<U: Into<Arc<String>>, P1: Into<Arc<String>>>(
&mut self,
username: U,
password: P1
) -> &mut Self
pub fn set_credentials<U: Into<Arc<String>>, P1: Into<Arc<String>>>( &mut self, username: U, password: P1 ) -> &mut Self
Username and password
pub async fn connect_to_v4(self) -> Client
pub async fn connect_to_v5(self) -> Client
Trait Implementations§
source§impl Clone for MqttOptions
impl Clone for MqttOptions
source§fn clone(&self) -> MqttOptions
fn clone(&self) -> MqttOptions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more