pub enum Protocol {
V3,
V4,
V5,
}Expand description
Protocol version handling and negotiation Represents the MQTT protocol version.
Variants§
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Returns the protocol name as a static string.
- For
Protocol::V3, the name is"MQIsdp". - For
Protocol::V4andProtocol::V5, the name is"MQTT".
§Examples
use mqute_codec::protocol::Protocol;
let protocol = Protocol::V3;
assert_eq!(protocol.name(), "MQIsdp");
let protocol = Protocol::V5;
assert_eq!(protocol.name(), "MQTT");Trait Implementations§
Source§impl TryFrom<u8> for Protocol
impl TryFrom<u8> for Protocol
Source§fn try_from(value: u8) -> Result<Self, Self::Error>
fn try_from(value: u8) -> Result<Self, Self::Error>
Attempts to convert a numeric value into a Protocol enum.
§Errors
Returns an Error::InvalidProtocolLevel if the value is not a valid protocol version.
§Examples
use mqute_codec::protocol::Protocol;
use mqute_codec::Error;
let protocol = Protocol::try_from(0x04).unwrap();
assert_eq!(protocol, Protocol::V4);
let result = Protocol::try_from(0x06);
assert!(result.is_err());impl Copy for Protocol
impl Eq for Protocol
impl StructuralPartialEq for Protocol
Auto Trait Implementations§
impl Freeze for Protocol
impl RefUnwindSafe for Protocol
impl Send for Protocol
impl Sync for Protocol
impl Unpin for Protocol
impl UnwindSafe for Protocol
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