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
impl ConnectOptionsBuilder
sourcepub fn new_from_existing(options: ConnectOptions) -> Self
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.
sourcepub fn with_keep_alive_interval_seconds(
&mut self,
keep_alive: Option<u16>
) -> &mut Self
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.
sourcepub fn with_rejoin_session_policy(
&mut self,
policy: RejoinSessionPolicy
) -> &mut Self
pub fn with_rejoin_session_policy( &mut self, policy: RejoinSessionPolicy ) -> &mut Self
Configures how the client will attempt to rejoin sessions
sourcepub fn with_client_id(&mut self, client_id: &str) -> &mut Self
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.
sourcepub fn with_username(&mut self, username: &str) -> &mut Self
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
sourcepub fn with_password(&mut self, password: &[u8]) -> &mut Self
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
sourcepub fn with_session_expiry_interval_seconds(
&mut self,
session_expiry_interval_seconds: u32
) -> &mut Self
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.
sourcepub fn with_request_response_information(
&mut self,
request_response_information: bool
) -> &mut Self
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.
sourcepub fn with_request_problem_information(
&mut self,
request_problem_information: bool
) -> &mut Self
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.
sourcepub fn with_receive_maximum(&mut self, receive_maximum: u16) -> &mut Self
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.
sourcepub fn with_topic_alias_maximum(
&mut self,
topic_alias_maximum: u16
) -> &mut Self
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.
sourcepub fn with_maximum_packet_size_bytes(
&mut self,
maximum_packet_size_bytes: u32
) -> &mut Self
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.
sourcepub fn with_will_delay_interval_seconds(
&mut self,
will_delay_interval_seconds: u32
) -> &mut Self
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.
sourcepub fn with_will(&mut self, will: PublishPacket) -> &mut Self
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
sourcepub fn with_user_properties(
&mut self,
user_properties: Vec<UserProperty>
) -> &mut Self
pub fn with_user_properties( &mut self, user_properties: Vec<UserProperty> ) -> &mut Self
Sets the MQTT5 user properties to include with all CONNECT packets.
sourcepub fn build(&self) -> ConnectOptions
pub fn build(&self) -> ConnectOptions
Builds a new ConnectOptions object for client construction