pub struct CreateOptionsBuilder { /* private fields */ }
Expand description

Builder to construct client creation options.

Examples

use paho_mqtt as mqtt;

let opts = mqtt::CreateOptionsBuilder::new()
                   .server_uri("tcp://localhost:1883")
                   .client_id("client1")
                   .finalize();

let cli = mqtt::AsyncClient::new(opts).unwrap();

Implementations

Constructs a builder with default options.

Sets the the URI to the MQTT broker. Alternately, the application can specify multiple servers via the connect options.

Arguments

server_uri The URI string to specify the server in the form protocol://host:port, where the protocol can be tcp or ssl, and the host can be an IP address or domain name.

Sets the client identifier string that is sent to the server. The client ID is a unique name to identify the client to the server, which can be used if the client desires the server to hold state about the session. If the client requests a clean session, this can be an empty string, in which case the server will assign a random name for the client.

The broker is required to honor a client ID of up to 23 bytes, but could honor longer ones, depending on the broker.

Note that if this is an empty string, the clean session parameter must be set to true.

Arguments

client_id A UTF-8 string identifying the client to the server.

Sets the type of persistence used by the client. The default is for the library to automatically use file persistence, although this can be turned off by specify None for a more performant, though possibly less reliable system.

Arguments

persist The type of persistence to use.

Sets a user-defined persistence store. This sets the persistence to use a custom one defined by the application. This can be anything that implements the ClientPersistence trait.

Arguments

persist An application-defined custom persistence store.

Sets the maximum number of messages that can be buffered for delivery.

When the client is off-line, this specifies the maximum number of messages that can be buffered. Even while connected, the library needs a small buffer to queue outbound messages. Setting it to zero disables off-line buffering but still keeps some slots open for on-line operation.

Arguments

n The maximum number of messages that can be buffered. Setting this to zero also disables any off-line buffering.

Allow the application to send (publish) messages while disconnected.

If this is disabled, then any time the app tries to publish while disconnected results in a “disconnected” error from the client. When enabled, the application can queue up to max_buffered_messages() while off-line.

Arguments

on Whether to allow off-line buffering in the client.

Sets the version of MQTT to use on the connect.

Arguments

ver The version of MQTT to use when connecting to the broker. * (0) try the latest version (3.1.1) and work backwards * (3) only try v3.1 * (4) only try v3.1.1 * (5) only try v5

Allow sending of messages while disconnected before a first successful connect.

When the maximum number of buffered messages is reached, delete the oldest rather than the newest.

If set, messages from persistence are restored on create. Defaults to true.

If set, QoS0 publish commands are persisted. Defaults to true.

Sets the user-defined data structure for the client.

Constructs a set of create options from the builder information.

Finalize the builder and create an asynchronous client.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.