[−][src]Struct paho_mqtt::client::Client
MQTT Client with a synchronous (blocking) API. This is simply a convenience wrapper around the asynchronous API, providing blocking calls with timeouts.
Implementations
impl Client
[src]
pub fn new<T>(opts: T) -> Result<Client> where
T: Into<CreateOptions>,
[src]
T: Into<CreateOptions>,
Creates a new MQTT client which can connect to an MQTT broker.
pub fn timeout(&self) -> Duration
[src]
Gets the default timeout used for synchronous operations.
pub fn set_timeout(&mut self, timeout: Duration)
[src]
Sets the default timeout used for synchronous operations.
Arguments
timeout
The timeout to use for synchronous calls, like
connect(), disconnect(), publish(), etc.
pub fn connect<T>(&self, opt_opts: T) -> Result<ServerResponse> where
T: Into<Option<ConnectOptions>>,
[src]
T: Into<Option<ConnectOptions>>,
Connects to an MQTT broker using the specified connect options.
pub fn disconnect<T>(&self, opt_opts: T) -> Result<()> where
T: Into<Option<DisconnectOptions>>,
[src]
T: Into<Option<DisconnectOptions>>,
Disconnects from the MQTT broker.
Arguments
opt_opts
Optional disconnect options. Specifying None
will use
default of immediate (zero timeout) disconnect.
pub fn disconnect_after(&self, timeout: Duration) -> Result<()>
[src]
Disconnect from the MQTT broker with a timeout. This will delay the disconnect for up to the specified timeout to allow in-flight messages to complete. This is the same as calling disconnect with options specifying a timeout.
Arguments
timeout
The amount of time to wait for the disconnect. This has
a resolution in milliseconds.
pub fn reconnect(&self) -> Result<ServerResponse>
[src]
Attempts to reconnect to the broker. This can only be called after a connection was initially made or attempted. It will retry with the same connect options.
pub fn is_connected(&self) -> bool
[src]
Determines if this client is currently connected to an MQTT broker.
pub fn publish(&self, msg: Message) -> Result<()>
[src]
Publishes a message to an MQTT broker
pub fn subscribe(&self, topic: &str, qos: i32) -> Result<ServerResponse>
[src]
Subscribes to a single topic.
Arguments
topic
The topic name
qos
The quality of service requested for messages
pub fn subscribe_many<T>(
&self,
topics: &[T],
qos: &[i32]
) -> Result<ServerResponse> where
T: AsRef<str>,
[src]
&self,
topics: &[T],
qos: &[i32]
) -> Result<ServerResponse> where
T: AsRef<str>,
Subscribes to multiple topics simultaneously.
Arguments
topic
The topic name
qos
The quality of service requested for messages
pub fn unsubscribe(&self, topic: &str) -> Result<()>
[src]
Unsubscribes from a single topic.
Arguments
topic
The topic to unsubscribe. It must match a topic from a
previous subscribe.
pub fn unsubscribe_many<T>(&self, topics: &[T]) -> Result<()> where
T: AsRef<str>,
[src]
T: AsRef<str>,
Unsubscribes from multiple topics simultaneously.
Arguments
topic
The topics to unsubscribe. Each must match a topic from a
previous subscribe.
pub fn start_consuming(&mut self) -> Receiver<Option<Message>>
[src]
Starts the client consuming messages. This starts the client receiving messages and placing them into an mpsc queue. It returns the receiving-end of the queue for the application to get the messages. This can be called at any time after the client is created, but it should be called before subscribing to any topics, otherwise messages can be lost.
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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>,