Struct mqtt_async_client::client::Client [−][src]
An MQTT client.
Start building an instance by calling Client::builder() to get a ClientBuilder, using the fluent builder pattern on ClientBuilder, then calling ClientBuilder::build(). For example:
let client = Client::builder() .set_host("example.com".to_owned()) .build();
Client
is expected to be Send
(passable between threads), but not
Sync
(usable by multiple threads at the same time).
Implementations
impl Client
[src]
pub fn builder() -> ClientBuilder
[src]
Start a fluent builder interface to construct a Client
.
pub async fn connect(&mut self) -> Result<()>
[src]
Open a connection to the configured MQTT broker.
pub async fn publish(&self, p: &Publish) -> Result<()>
[src]
Publish some data on a topic.
Note that this method takes &self
. This means a caller can
create several publish futures to publish several payloads of
data simultaneously without waiting for responses.
pub async fn subscribe(&mut self, s: Subscribe) -> Result<SubscribeResult>
[src]
Subscribe to some topics.read_subscriptions
will return
data for them.
pub async fn unsubscribe(&mut self, u: Unsubscribe) -> Result<()>
[src]
Unsubscribe from some topics. read_subscriptions
will no
longer return data for them.
pub async fn read_subscriptions(&mut self) -> Result<ReadResult>
[src]
Wait for the next Publish packet for one of this Client's subscriptions.
pub async fn disconnect(&mut self) -> Result<()>
[src]
Gracefully close the connection to the server.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
[src]
impl Send for Client
[src]
impl Sync for Client
[src]
impl Unpin for Client
[src]
impl !UnwindSafe for Client
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,