pub struct Client;
Expand description
MQTT Client role type
Represents an MQTT client that connects to MQTT brokers. Clients can:
- Establish connections to brokers using CONNECT packets
- Publish messages to topics
- Subscribe to topic filters to receive messages
- Send heartbeat PINGREQ packets
- Gracefully disconnect using DISCONNECT packets
This is a zero-sized type used purely for compile-time role identification. The actual client behavior is implemented in the connection logic that uses this role type as a generic parameter.
§Protocol Restrictions
When using the Client role, certain MQTT packets are restricted:
- Cannot send CONNACK (connection acknowledgment)
- Cannot send SUBACK (subscription acknowledgment)
- Cannot send UNSUBACK (unsubscription acknowledgment)
- Cannot send PINGRESP (ping response)
§Examples
ⓘ
use mqtt_protocol_core::mqtt;
// Client role is typically used as a generic parameter
type ClientConnection = mqtt::connection::GenericConnection<mqtt::connection::Client, u16>;
// Role constants can be checked at compile time
assert_eq!(mqtt::connection::Client::IS_CLIENT, true);
assert_eq!(mqtt::connection::Client::IS_SERVER, false);
Trait Implementations§
Source§impl<PacketIdType> RecvBehavior<Client, PacketIdType> for GenericConnection<Client, PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> RecvBehavior<Client, PacketIdType> for GenericConnection<Client, PacketIdType>where
PacketIdType: IsPacketId,
Source§impl RoleType for Client
Implementation of RoleType
for Client
impl RoleType for Client
Implementation of RoleType
for Client
Configures the Client role type with the appropriate role flags.
Only the IS_CLIENT
flag is set to true
, clearly identifying
this type as representing an MQTT client role.
Source§impl<PacketIdType> Sendable<Client, PacketIdType> for GenericPacket<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> Sendable<Client, PacketIdType> for GenericPacket<PacketIdType>where
PacketIdType: IsPacketId,
fn dispatch_send( self, connection: &mut GenericConnection<Client, PacketIdType>, ) -> Vec<GenericEvent<PacketIdType>>
impl SendableRole<Client> for Auth
impl SendableRole<Client> for Connect
impl SendableRole<Client> for Connect
impl SendableRole<Client> for Disconnect
impl SendableRole<Client> for Disconnect
impl<PacketIdType> SendableRole<Client> for GenericPuback<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPuback<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPubcomp<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPubcomp<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPublish<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPublish<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPubrec<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPubrec<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPubrel<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericPubrel<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericSubscribe<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericSubscribe<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericUnsubscribe<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Client> for GenericUnsubscribe<PacketIdType>where
PacketIdType: IsPacketId,
impl SendableRole<Client> for Pingreq
impl SendableRole<Client> for Pingreq
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more