pub struct MqttClientConfig<S> {
pub connection: MqttOptions,
pub settings: ClientSettings,
/* private fields */
}
Expand description
Configuration for MQTT client creation
Fields§
§connection: MqttOptions
Underlying MQTT connection options (from rumqttc)
settings: ClientSettings
Client-level performance and behavior settings
Implementations§
Source§impl<S> MqttClientConfig<S>
impl<S> MqttClientConfig<S>
Sourcepub fn new(client_id: &str, host: &str, port: u16) -> MqttClientConfig<S>
pub fn new(client_id: &str, host: &str, port: u16) -> MqttClientConfig<S>
Create config with default settings
Sourcepub fn from_url(url: &str) -> Result<MqttClientConfig<S>, OptionError>
pub fn from_url(url: &str) -> Result<MqttClientConfig<S>, OptionError>
Parse configuration from MQTT URL
Supports: tcp://, mqtt://, ssl://, mqtts://, ws://, wss://
Sourcepub fn localhost(client_id: &str) -> MqttClientConfig<S>
pub fn localhost(client_id: &str) -> MqttClientConfig<S>
Create config for localhost:1883
Sourcepub fn with_last_will<T>(
&mut self,
last_will: TypedLastWill<T>,
) -> Result<&mut MqttClientConfig<S>, MqttClientError>where
S: MessageSerializer<T>,
pub fn with_last_will<T>(
&mut self,
last_will: TypedLastWill<T>,
) -> Result<&mut MqttClientConfig<S>, MqttClientError>where
S: MessageSerializer<T>,
Configure Last Will and Testament message
The Last Will message will be published by the broker if this client disconnects unexpectedly. Payload is serialized immediately using the configured serializer type.
§Example
let mut config = MqttClientConfig::<BincodeSerializer>::new("client", "broker", 1883);
// Create last will manually (in real code, use generated methods from #[mqtt_topic])
let last_will = TypedLastWill {
topic: "devices/123/status".to_string(),
payload: "offline".to_string(),
qos: QoS::AtLeastOnce,
retain: true,
};
config.with_last_will(last_will)?;
§Errors
Returns MqttClientError::Serialization
if payload serialization fails.
Trait Implementations§
Source§impl<S> Clone for MqttClientConfig<S>where
S: Clone,
impl<S> Clone for MqttClientConfig<S>where
S: Clone,
Source§fn clone(&self) -> MqttClientConfig<S>
fn clone(&self) -> MqttClientConfig<S>
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 moreAuto Trait Implementations§
impl<S> !Freeze for MqttClientConfig<S>
impl<S> !RefUnwindSafe for MqttClientConfig<S>
impl<S> Send for MqttClientConfig<S>where
S: Send,
impl<S> Sync for MqttClientConfig<S>where
S: Sync,
impl<S> Unpin for MqttClientConfig<S>where
S: Unpin,
impl<S> !UnwindSafe for MqttClientConfig<S>
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