pub struct Server;
Expand description
MQTT Server/Broker role type
Represents an MQTT broker/server that accepts client connections. Servers can:
- Accept CONNECT packets from clients and respond with CONNACK
- Receive published messages and route them to subscribers
- Handle SUBSCRIBE packets and respond with SUBACK
- Handle UNSUBSCRIBE packets and respond with UNSUBACK
- Respond to PINGREQ packets with PINGRESP
- Manage client sessions and retained messages
This is a zero-sized type used purely for compile-time role identification. The actual server behavior is implemented in the connection logic that uses this role type as a generic parameter.
§Protocol Restrictions
When using the Server role, certain MQTT packets are restricted:
- Cannot send CONNECT (connection request)
- Cannot send SUBSCRIBE (subscription request)
- Cannot send UNSUBSCRIBE (unsubscription request)
- Cannot send PINGREQ (ping request)
§Examples
ⓘ
use mqtt_protocol_core::mqtt;
// Server role is typically used as a generic parameter
type ServerConnection = mqtt::connection::GenericConnection<mqtt::connection::Server, u16>;
// Role constants can be checked at compile time
assert_eq!(mqtt::connection::Server::IS_CLIENT, false);
assert_eq!(mqtt::connection::Server::IS_SERVER, true);
Trait Implementations§
Source§impl<PacketIdType> RecvBehavior<Server, PacketIdType> for GenericConnection<Server, PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> RecvBehavior<Server, PacketIdType> for GenericConnection<Server, PacketIdType>where
PacketIdType: IsPacketId,
Source§impl RoleType for Server
Implementation of RoleType
for Server
impl RoleType for Server
Implementation of RoleType
for Server
Configures the Server role type with the appropriate role flags.
Only the IS_SERVER
flag is set to true
, clearly identifying
this type as representing an MQTT server/broker role.
Source§impl<PacketIdType> Sendable<Server, PacketIdType> for GenericPacket<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> Sendable<Server, PacketIdType> for GenericPacket<PacketIdType>where
PacketIdType: IsPacketId,
fn dispatch_send( self, connection: &mut GenericConnection<Server, PacketIdType>, ) -> Vec<GenericEvent<PacketIdType>>
impl SendableRole<Server> for Auth
impl SendableRole<Server> for Connack
impl SendableRole<Server> for Connack
impl SendableRole<Server> for Disconnect
impl<PacketIdType> SendableRole<Server> for GenericPuback<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPuback<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPubcomp<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPubcomp<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPublish<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPublish<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPubrec<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPubrec<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPubrel<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericPubrel<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericSuback<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericSuback<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericUnsuback<PacketIdType>where
PacketIdType: IsPacketId,
impl<PacketIdType> SendableRole<Server> for GenericUnsuback<PacketIdType>where
PacketIdType: IsPacketId,
impl SendableRole<Server> for Pingresp
impl SendableRole<Server> for Pingresp
Auto Trait Implementations§
impl Freeze for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnwindSafe for Server
Blanket Implementations§
Source§impl<T> AsConcrete<T> for T
impl<T> AsConcrete<T> for T
fn as_concrete(&self) -> Option<&T>
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