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(self, will: LastWill) -> 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(self, incoming: usize, outgoing: usize) -> Self
pub fn set_max_packet_size(self, incoming: usize, outgoing: usize) -> 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(self, clean_session: bool) -> Self
pub fn set_clean_session(self, clean_session: bool) -> 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>>>(
self,
username: U,
password: P1
) -> Self
pub fn set_credentials<U: Into<Arc<String>>, P1: Into<Arc<String>>>( self, username: U, password: P1 ) -> Self
Username and password
pub async fn connect_to_v4(self) -> Result<(Client, ClientRx)>
pub async fn connect_to_v5(self) -> Result<(Client, ClientRx)>
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 moreAuto Trait Implementations§
impl RefUnwindSafe for MqttOptions
impl Send for MqttOptions
impl Sync for MqttOptions
impl Unpin for MqttOptions
impl UnwindSafe for MqttOptions
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more