pub struct MqttClient<F> { /* private fields */ }
Expand description
Type-safe MQTT client with automatic subscription management.
Provides typed publishers and subscribers with automatic serialization.
Connection lifecycle is managed separately via MqttConnection
.
Implementations§
Source§impl<F> MqttClient<F>
impl<F> MqttClient<F>
Sourcepub async fn connect(
url: &str,
) -> Result<(MqttClient<F>, MqttConnection), MqttClientError>
pub async fn connect( url: &str, ) -> Result<(MqttClient<F>, MqttConnection), MqttClientError>
Create MQTT client with default configuration.
Returns both client and connection handle. Keep connection alive
for the session duration, call connection.shutdown()
when done.
Sourcepub async fn connect_with_config(
config: MqttClientConfig<F>,
) -> Result<(MqttClient<F>, MqttConnection), MqttClientError>
pub async fn connect_with_config( config: MqttClientConfig<F>, ) -> Result<(MqttClient<F>, MqttConnection), MqttClientError>
Create a new MQTT client with custom configuration
Sourcepub fn get_publisher<T>(
&self,
topic: impl Into<ArcStr>,
) -> Result<MqttPublisher<T, F>, TopicError>where
F: MessageSerializer<T>,
pub fn get_publisher<T>(
&self,
topic: impl Into<ArcStr>,
) -> Result<MqttPublisher<T, F>, TopicError>where
F: MessageSerializer<T>,
Create typed publisher for specific topic.
Topic must not contain wildcard characters (+
, #
).
Sourcepub async fn subscribe<T>(
&self,
topic: impl TryInto>,
) -> Result<MqttSubscriber<T, F>, MqttClientError>where
T: 'static + Send + Sync,
F: MessageSerializer<T>,
<impl TryInto<TopicPatternPath> as TryInto<TopicPatternPath>>::Error: Into<MqttClientError>,
pub async fn subscribe<T>(
&self,
topic: impl TryInto>,
) -> Result<MqttSubscriber<T, F>, MqttClientError>where
T: 'static + Send + Sync,
F: MessageSerializer<T>,
<impl TryInto<TopicPatternPath> as TryInto<TopicPatternPath>>::Error: Into<MqttClientError>,
where
T: 'static + Send + Sync,
F: MessageSerializer<T>,
<impl TryInto<TopicPatternPath> as TryInto<TopicPatternPath>>::Error: Into<MqttClientError>,
Subscribe to topic pattern with default configuration.
Supports MQTT wildcards: +
(single level), #
(multi-level).
Sourcepub async fn subscribe_with_config<T>(
&self,
topic: impl TryInto>,
config: SubscriptionConfig,
) -> Result<MqttSubscriber<T, F>, MqttClientError>where
T: 'static + Send + Sync,
F: MessageSerializer<T>,
<impl TryInto<TopicPatternPath> as TryInto<TopicPatternPath>>::Error: Into<MqttClientError>,
pub async fn subscribe_with_config<T>(
&self,
topic: impl TryInto>,
config: SubscriptionConfig,
) -> Result<MqttSubscriber<T, F>, MqttClientError>where
T: 'static + Send + Sync,
F: MessageSerializer<T>,
<impl TryInto<TopicPatternPath> as TryInto<TopicPatternPath>>::Error: Into<MqttClientError>,
where
T: 'static + Send + Sync,
F: MessageSerializer<T>,
<impl TryInto<TopicPatternPath> as TryInto<TopicPatternPath>>::Error: Into<MqttClientError>,
Subscribe with custom configuration (QoS, caching strategy)
Trait Implementations§
Source§impl<F> Clone for MqttClient<F>where
F: Clone,
impl<F> Clone for MqttClient<F>where
F: Clone,
Source§fn clone(&self) -> MqttClient<F>
fn clone(&self) -> MqttClient<F>
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<F> Freeze for MqttClient<F>where
F: Freeze,
impl<F> RefUnwindSafe for MqttClient<F>where
F: RefUnwindSafe,
impl<F> Send for MqttClient<F>where
F: Send,
impl<F> Sync for MqttClient<F>where
F: Sync,
impl<F> Unpin for MqttClient<F>where
F: Unpin,
impl<F> UnwindSafe for MqttClient<F>where
F: UnwindSafe,
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