Struct mosquitto_client::Mosquitto [−][src]
pub struct Mosquitto { /* fields omitted */ }
Mosquitto client
Methods
impl Mosquitto
[src]
impl Mosquitto
pub fn new(id: &str) -> Mosquitto
[src]
pub fn new(id: &str) -> Mosquitto
create a new mosquitto instance, providing a client name. Clients connecting to a broker must have unique names
pub fn new_session(id: &str, clean_session: bool) -> Mosquitto
[src]
pub fn new_session(id: &str, clean_session: bool) -> Mosquitto
create a new mosquitto instance with specified clean session flag. Clients connecting to a broker must have unique names
pub fn callbacks<'a, T>(&'a self, data: T) -> Callbacks<'a, T>
[src]
pub fn callbacks<'a, T>(&'a self, data: T) -> Callbacks<'a, T>
create a Callback object so you can listen to events.
pub fn connect(&self, host: &str, port: u32) -> Result<()>
[src]
pub fn connect(&self, host: &str, port: u32) -> Result<()>
connect to the broker. You can only be fully sure that a connection succeeds after the on_connect callback returns non-zero
pub fn connect_wait(&self, host: &str, port: u32, millis: i32) -> Result<()>
[src]
pub fn connect_wait(&self, host: &str, port: u32, millis: i32) -> Result<()>
connect to the broker, waiting for success.
pub fn threaded(&self)
[src]
pub fn threaded(&self)
call if you wish to use Mosquitto in a multithreaded environment.
pub fn reconnect(&self) -> Result<()>
[src]
pub fn reconnect(&self) -> Result<()>
reconnect to the broker
pub fn reconnect_delay_set(
&self,
delay: u32,
delay_max: u32,
exponential_backoff: bool
) -> Result<()>
[src]
pub fn reconnect_delay_set(
&self,
delay: u32,
delay_max: u32,
exponential_backoff: bool
) -> Result<()>
pub fn subscribe<'a>(&'a self, sub: &str, qos: u32) -> Result<TopicMatcher<'a>>
[src]
pub fn subscribe<'a>(&'a self, sub: &str, qos: u32) -> Result<TopicMatcher<'a>>
subscribe to an MQTT topic, with a desired quality-of-service.
The returned value can be used to directly match
against received messages, and has a mid
field identifying
the subscribing request. on_subscribe will be called with this
identifier.
pub fn unsubscribe(&self, sub: &str) -> Result<i32>
[src]
pub fn unsubscribe(&self, sub: &str) -> Result<i32>
unsubcribe from an MQTT topic - on_unsubscribe
callback will be called.
pub fn publish(
&self,
topic: &str,
payload: &[u8],
qos: u32,
retain: bool
) -> Result<i32>
[src]
pub fn publish(
&self,
topic: &str,
payload: &[u8],
qos: u32,
retain: bool
) -> Result<i32>
publish an MQTT message to the broker, returning message id.
Quality-of-service and whether retained can be specified.
To be sure, check the message id passed to the on_publish
callback
pub fn will_set(
&self,
topic: &str,
payload: &[u8],
qos: u32,
retain: bool
) -> Result<()>
[src]
pub fn will_set(
&self,
topic: &str,
payload: &[u8],
qos: u32,
retain: bool
) -> Result<()>
pub fn will_clear(&self) -> Result<()>
[src]
pub fn will_clear(&self) -> Result<()>
pub fn publish_wait(
&self,
topic: &str,
payload: &[u8],
qos: u32,
retain: bool,
millis: i32
) -> Result<i32>
[src]
pub fn publish_wait(
&self,
topic: &str,
payload: &[u8],
qos: u32,
retain: bool,
millis: i32
) -> Result<i32>
publish an MQTT message to the broker, returning message id after waiting for successful publish
pub fn disconnect(&self) -> Result<()>
[src]
pub fn disconnect(&self) -> Result<()>
explicitly disconnect from the broker.
pub fn do_loop(&self, timeout: i32) -> Result<()>
[src]
pub fn do_loop(&self, timeout: i32) -> Result<()>
process network events for at most timeout
milliseconds.
-1 will mean the default, 1000ms.
pub fn loop_forever(&self, timeout: i32) -> Result<()>
[src]
pub fn loop_forever(&self, timeout: i32) -> Result<()>
process network events. This will handle intermittent disconnects for you, but will return after an explicit disconnect() call
pub fn loop_until_disconnect(&self, timeout: i32) -> Result<()>
[src]
pub fn loop_until_disconnect(&self, timeout: i32) -> Result<()>
loop forever, but do not regard an explicit disconnect as an error.
pub fn tls_set<P1, P2, P3>(
&self,
cafile: P1,
certfile: P2,
keyfile: P3,
passphrase: Option<&str>
) -> Result<()> where
P1: AsRef<Path>,
P2: AsRef<Path>,
P3: AsRef<Path>,
[src]
pub fn tls_set<P1, P2, P3>(
&self,
cafile: P1,
certfile: P2,
keyfile: P3,
passphrase: Option<&str>
) -> Result<()> where
P1: AsRef<Path>,
P2: AsRef<Path>,
P3: AsRef<Path>,
Set TLS parameters
cafile
is a file containing the PEM encoded trusted CA certificate
certfile
is a file containing the PEM encoded certificate file for this client.
keyfile
is a file containing the PEM encoded private key for this client.
password
if the private key is encrypted
pub fn tls_psk_set(
&self,
psk: &str,
identity: &str,
ciphers: Option<&str>
) -> Result<()>
[src]
pub fn tls_psk_set(
&self,
psk: &str,
identity: &str,
ciphers: Option<&str>
) -> Result<()>
Set TLS PSK parameters
psk
is the pre-shared-key in hex format with no leading "0x"
identity
is the identity of this client. May be used as the username
ciphers
is an optional string describing the PSK ciphers available for use