Struct sage_mqtt::Connect[][src]

pub struct Connect {
Show 14 fields pub clean_start: bool, pub user_name: Option<String>, pub password: Option<Vec<u8>>, pub keep_alive: u16, pub session_expiry_interval: Option<u32>, pub receive_maximum: u16, pub maximum_packet_size: Option<u32>, pub topic_alias_maximum: u16, pub request_response_information: bool, pub request_problem_information: bool, pub user_properties: Vec<(String, String)>, pub authentication: Option<Authentication>, pub client_id: Option<ClientID>, pub will: Option<Will>,
}
Expand description

The Connect control packet is used to open a session. It is the first Packet a client must send to a server once the connection is established. A Connect packet can only be sent once for each connection.

Session and connection

A unique connection can only send a Connect packet once. If the server received a second Connect packet over a same connection, it is considered as a protocol error. Yet, a same session can continue accross different sequences of connections. In that case, clean_start must be set to false (default) to continue the session.

Client identifier

The client identifier is a server-unique String used to identify the client accross operations. It is possible not to give a client identifier to the server by setting client_id to either None or an empty string. In that case the server will decide itself for an identifier and return it into the CONNACK packet.

Fields

clean_start: bool

If set, the server will start a new session and drop any existing one if any.

user_name: Option<String>

An optional user name to send to the server.

password: Option<Vec<u8>>

An option password to send to the server.

keep_alive: u16

Specifies the maximum amount of time the client and the server may not communicate with each other. This value is expressed in seconds. If the server does not receive any packet from the client in one and a half times this interval, it will close the connection. Likewise, the client will close the connection under the same condition. The default keep alive value is 600 (10mn). Not that the keep alive mechanism is deactivated if the value is 0.

session_expiry_interval: Option<u32>

Once the connection is closed, the client and server still keep the session active during a certain amount of time expressed in seconds.

  • If the value is 0 (default) the session ends when the connection is closed.
  • If the value is 0xFFFFFFFF the session never expires. The client can override the session expiry interval within the DISCONNECT packet.
receive_maximum: u16

This value sets the maximum number of AtLeastOnce and ExactlyOnce packets that should be processed concurrently. There is no such limit for QoS AtMostOnce packets. The default value is 65_535

maximum_packet_size: Option<u32>

Defines the maximum size per packet the client is willing to receive from the server. It is a procotol error to send a packet which size exceeds this value and the client is expected to disconnect from the server with a PacketTooLarge error. This value cannot be 0. Sending or receiving a CONNECT packet with a maximum_packet_size of value 0 is a procotol error. maximum_packet_size is None (default), there is no size limit.

topic_alias_maximum: u16

Topic aliases are a way to reduce the size of packets by substituting aliases (which are strings) to integer values. The number of aliases allowed by the client from the server is defined with the topic_alias_maximum. It can be 0, meaning aliases are entirely disallowed.

request_response_information: bool

This flag can be set to ask the server to send back response information that can be used as an hint by the client to determine a response topic used in Request/Response type communication. This is only an optional hint and the server is allowed not to send any reponse information even if the value of the field is true. By default, request_response_information is false.

request_problem_information: bool

In any packet sent by the server that contains a ReasonCode, the latter can be described using a reason string or user properties. These are called “problem information”. If request_problem_information is true the server is allowed to sent problem information in any packet with a ReasonCode. If false (default), the server is only allowed to send problem information on Publish, Connack and Disconnect packets.

user_properties: Vec<(String, String)>

General purpose properties By default, a Connect packet has no properties.

authentication: Option<Authentication>

Define an Authentication structure to provide enhanced authentication. By default, authentication is None, which means no or basic authentication using only user_name and password.

client_id: Option<ClientID>

The client id is an identifier that uniquely represents the client from the server point of view. The client id is used to ensure AtLeastOnce and ExactlyOnce qualities of service. A client id is mandatory within a session. Yet, the Connect packet may omit if by setting client_id to None (default). In that case the id is created by the server and returns to the client with the Connack packet.

will: Option<Will>

The client’s Last Will to send in case of ungraceful disconnection. This is optional and default is None.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

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.