Struct gneiss_mqtt::config::ConnectOptionsBuilder

source ·
pub struct ConnectOptionsBuilder { /* private fields */ }
Expand description

A builder for connection-related options on the client.

These options will determine packet field values for the CONNECT packet sent out by the client on each connection attempt.

Implementations§

source§

impl ConnectOptionsBuilder

source

pub fn new() -> Self

Creates a new builder object for ConnectOptions

source

pub fn new_from_existing(options: ConnectOptions) -> Self

Creates a new builder object for ConnectOptions using existing an existing ConnectOptions value as a starting point. Useful for internally tweaking user-supplied configuration.

source

pub fn with_keep_alive_interval_seconds( &mut self, keep_alive: Option<u16> ) -> &mut Self

Sets the maximum time interval, in seconds, that is permitted to elapse between the point at which the client finishes transmitting one MQTT packet and the point it starts sending the next. The client will use PINGREQ packets to maintain this property.

If the responding CONNACK contains a keep alive property value, then that is the negotiated keep alive value. Otherwise, the keep alive sent by the client is the negotiated value.

See MQTT5 Keep Alive

If the final negotiated value is 0, then that means no keep alive will be used. Such a state is not advised due to scenarios where TCP connections can be invisibly dropped by routers/firewalls within the full connection circuit.

source

pub fn with_rejoin_session_policy( &mut self, policy: RejoinSessionPolicy ) -> &mut Self

Configures how the client will attempt to rejoin sessions

source

pub fn with_client_id(&mut self, client_id: &str) -> &mut Self

Sets a unique string identifying the client to the server. Used to restore session state between connections.

If left empty, the broker will auto-assign a unique client id. When reconnecting, the mqtt5 client will always use the auto-assigned client id.

See MQTT5 Client Identifier

source

pub fn with_username(&mut self, username: &str) -> &mut Self

Sets a string value that the server may use for client authentication and authorization.

See MQTT5 User Name

source

pub fn with_password(&mut self, password: &[u8]) -> &mut Self

Sets opaque binary data that the server may use for client authentication and authorization.

See MQTT5 Password

source

pub fn with_session_expiry_interval_seconds( &mut self, session_expiry_interval_seconds: u32 ) -> &mut Self

Sets the time interval, in seconds, that the client requests the server to persist this connection’s MQTT session state for. Has no meaning if the client has not been configured to rejoin sessions. Must be non-zero in order to successfully rejoin a session.

If the responding CONNACK contains a session expiry property value, then that is the negotiated session expiry value. Otherwise, the session expiry sent by the client is the negotiated value.

See MQTT5 Session Expiry Interval

source

pub fn with_request_response_information( &mut self, request_response_information: bool ) -> &mut Self

Sets whether or not the server should send response information in the subsequent CONNACK. This response information may be used to set up request-response implementations over MQTT, but doing so is outside the scope of the MQTT5 spec and client.

See MQTT5 Request Response Information

source

pub fn with_request_problem_information( &mut self, request_problem_information: bool ) -> &mut Self

Sets whether or not the server should send additional diagnostic information (via response string or user properties) in DISCONNECT or CONNACK packets from the server.

See MQTT5 Request Problem Information

source

pub fn with_receive_maximum(&mut self, receive_maximum: u16) -> &mut Self

Sets a value that notifies the server of the maximum number of in-flight Qos 1 and 2 messages the client is willing to handle. If omitted, then no limit is requested.

See MQTT5 Receive Maximum

source

pub fn with_topic_alias_maximum( &mut self, topic_alias_maximum: u16 ) -> &mut Self

Sets a value that controls the maximum number of topic aliases that the client will accept for incoming publishes. An inbound topic alias larger than this number is a protocol error. If this value is not specified, the client does not support inbound topic aliasing.

See MQTT5 Topic Alias Maximum

source

pub fn with_maximum_packet_size_bytes( &mut self, maximum_packet_size_bytes: u32 ) -> &mut Self

A setting that notifies the server of the maximum packet size the client is willing to handle. If omitted, then no limit beyond the natural limits of MQTT packet size is requested.

See MQTT5 Maximum Packet Size

source

pub fn with_will_delay_interval_seconds( &mut self, will_delay_interval_seconds: u32 ) -> &mut Self

Sets the time interval, in seconds, that the server should wait (for a session reconnection) before sending the will message associated with the connection’s session. If omitted, the server will send the will when the associated session is destroyed. If the session is destroyed before a will delay interval has elapsed, then the will must be sent at the time of session destruction.

See MQTT5 Will Delay Interval

source

pub fn with_will(&mut self, will: PublishPacket) -> &mut Self

Configures a message to be published when the connection’s session is destroyed by the server or when the will delay interval has elapsed, whichever comes first. If undefined, then nothing will be sent.

See MQTT5 Will

source

pub fn with_user_properties( &mut self, user_properties: Vec<UserProperty> ) -> &mut Self

Sets the MQTT5 user properties to include with all CONNECT packets.

See MQTT5 User Property

source

pub fn build(&self) -> ConnectOptions

Builds a new ConnectOptions object for client construction

Trait Implementations§

source§

impl Debug for ConnectOptionsBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ConnectOptionsBuilder

source§

fn default() -> ConnectOptionsBuilder

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V