@@ -26,6 +26,7 @@ use num_enum::TryFromPrimitive;
2626use serde:: { Serialize , Serializer } ;
2727
2828#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
29+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
2930#[ repr( u16 ) ]
3031pub enum MqttError {
3132 // MQTT protocol based error
@@ -210,6 +211,7 @@ impl core::convert::TryFrom<u8> for MqttError {
210211
211212/// MQTT v3.1.1 Connect Return Code
212213#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
214+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
213215#[ repr( u8 ) ]
214216pub enum ConnectReturnCode {
215217 Accepted = 0 , // Connection accepted (not an error)
@@ -254,6 +256,7 @@ impl Serialize for ConnectReturnCode {
254256
255257/// MQTT v3.1.1 SUBACK Return Code
256258#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
259+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
257260#[ repr( u8 ) ]
258261pub enum SubackReturnCode {
259262 SuccessMaximumQos0 = 0x00 , // Success with QoS0 (not an error)
@@ -297,6 +300,7 @@ impl Serialize for SubackReturnCode {
297300
298301/// MQTT v5.0 Connect Reason Code (used in CONNACK)
299302#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
303+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
300304#[ repr( u8 ) ]
301305pub enum ConnectReasonCode {
302306 Success = 0x00 , // Success (not an error)
@@ -370,6 +374,7 @@ impl From<ConnectReasonCode> for MqttError {
370374}
371375
372376#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
377+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
373378#[ repr( u8 ) ]
374379pub enum DisconnectReasonCode {
375380 NormalDisconnection = 0x00 ,
@@ -501,6 +506,7 @@ impl From<MqttError> for DisconnectReasonCode {
501506}
502507
503508#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
509+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
504510#[ repr( u8 ) ]
505511pub enum SubackReasonCode {
506512 GrantedQos0 = 0x00 ,
@@ -566,6 +572,7 @@ impl From<SubackReasonCode> for MqttError {
566572}
567573
568574#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
575+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
569576#[ repr( u8 ) ]
570577pub enum UnsubackReasonCode {
571578 Success = 0x00 ,
@@ -618,6 +625,7 @@ impl From<UnsubackReasonCode> for MqttError {
618625}
619626
620627#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
628+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
621629#[ repr( u8 ) ]
622630pub enum PubackReasonCode {
623631 Success = 0x00 ,
@@ -674,6 +682,7 @@ impl From<PubackReasonCode> for MqttError {
674682}
675683
676684#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
685+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
677686#[ repr( u8 ) ]
678687pub enum PubrecReasonCode {
679688 Success = 0x00 ,
@@ -729,6 +738,7 @@ impl From<PubrecReasonCode> for MqttError {
729738}
730739
731740#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
741+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
732742#[ repr( u8 ) ]
733743pub enum PubrelReasonCode {
734744 Success = 0x00 ,
@@ -771,6 +781,7 @@ impl From<PubrelReasonCode> for MqttError {
771781}
772782
773783#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
784+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
774785#[ repr( u8 ) ]
775786pub enum PubcompReasonCode {
776787 Success = 0x00 ,
@@ -813,6 +824,7 @@ impl From<PubcompReasonCode> for MqttError {
813824}
814825
815826#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , TryFromPrimitive ) ]
827+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
816828#[ repr( u8 ) ]
817829pub enum AuthReasonCode {
818830 Success = 0x00 ,
0 commit comments