pub struct ConnectOptions {
pub client_id: String,
pub keep_alive: Duration,
pub clean_start: bool,
pub username: Option<String>,
pub password: Option<Vec<u8>>,
pub will: Option<WillMessage>,
pub properties: ConnectProperties,
pub session_config: SessionConfig,
pub reconnect_config: ReconnectConfig,
}
Expand description
Connection options for MQTT client
§Examples
use mqtt5::{ConnectOptions, WillMessage, QoS};
use std::time::Duration;
// Basic connection options
let options = ConnectOptions::new("my-client-id")
.with_clean_start(false)
.with_keep_alive(Duration::from_secs(30));
// With authentication
let options = ConnectOptions::new("secure-client")
.with_credentials("mqtt_user", b"secure_password");
// With Last Will and Testament
let will = WillMessage::new("status/offline", b"Client disconnected")
.with_qos(QoS::AtLeastOnce)
.with_retain(true);
let options = ConnectOptions::new("monitored-client")
.with_will(will);
// With automatic reconnection
let options = ConnectOptions::new("persistent-client")
.with_automatic_reconnect(true)
.with_reconnect_delay(Duration::from_secs(5), Duration::from_secs(60));
Fields§
§client_id: String
§keep_alive: Duration
§clean_start: bool
§username: Option<String>
§password: Option<Vec<u8>>
§will: Option<WillMessage>
§properties: ConnectProperties
§session_config: SessionConfig
§reconnect_config: ReconnectConfig
Implementations§
Source§impl ConnectOptions
impl ConnectOptions
pub fn new(client_id: impl Into<String>) -> Self
pub fn with_keep_alive(self, duration: Duration) -> Self
pub fn with_clean_start(self, clean: bool) -> Self
pub fn with_credentials( self, username: impl Into<String>, password: impl Into<Vec<u8>>, ) -> Self
pub fn with_will(self, will: WillMessage) -> Self
pub fn with_session_expiry_interval(self, interval: u32) -> Self
pub fn with_receive_maximum(self, receive_maximum: u16) -> Self
pub fn with_automatic_reconnect(self, enabled: bool) -> Self
pub fn with_reconnect_delay(self, initial: Duration, max: Duration) -> Self
pub fn with_max_reconnect_attempts(self, attempts: u32) -> Self
Trait Implementations§
Source§impl Clone for ConnectOptions
impl Clone for ConnectOptions
Source§fn clone(&self) -> ConnectOptions
fn clone(&self) -> ConnectOptions
Returns a duplicate 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 moreSource§impl Debug for ConnectOptions
impl Debug for ConnectOptions
Auto Trait Implementations§
impl Freeze for ConnectOptions
impl RefUnwindSafe for ConnectOptions
impl Send for ConnectOptions
impl Sync for ConnectOptions
impl Unpin for ConnectOptions
impl UnwindSafe for ConnectOptions
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