Trait GenericPacketDisplay

Source
pub trait GenericPacketDisplay {
    // Required methods
    fn fmt_debug(&self, f: &mut Formatter<'_>) -> Result;
    fn fmt_display(&self, f: &mut Formatter<'_>) -> Result;
}

Required Methods§

Source

fn fmt_debug(&self, f: &mut Formatter<'_>) -> Result

Source

fn fmt_display(&self, f: &mut Formatter<'_>) -> Result

Implementors§

Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::Connack

Implementation of GenericPacketDisplay for generic formatting operations

Provides a common interface for formatting operations that can be used generically across different MQTT packet types. This enables uniform display handling in collections and generic contexts.

This trait is useful when implementing logging systems, debugging tools, or user interfaces that need to display various MQTT packet types in a consistent manner without knowing the specific packet type at compile time.

§Methods

  • fmt_debug(): Delegates to the Debug trait implementation
  • fmt_display(): Delegates to the Display trait implementation

Both methods produce JSON-formatted output for consistency and readability.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;
use mqtt_protocol_core::mqtt::result_code::ConnectReturnCode;

let connack = mqtt::packet::v3_1_1::Connack::builder()
    .session_present(false)
    .return_code(ConnectReturnCode::Accepted)
    .build()
    .unwrap();

// Use generic display methods
let debug_output = format!("{:?}", connack);
let display_output = format!("{}", connack);

// Can be used in generic contexts
fn log_packet<T: GenericPacketDisplay>(packet: &T) {
    println!("Packet: {}", packet); // Uses fmt_display
}

log_packet(&connack);
Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::Connect

Implementation of GenericPacketDisplay for CONNECT packets

This trait provides a generic interface for packet display operations, allowing CONNECT packets to be formatted uniformly with other packet types.

The implementation delegates to the standard Debug and Display traits.

Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::Disconnect

Implements the generic packet display trait for DISCONNECT packets

This trait provides a common display interface for all MQTT packet types, enabling consistent formatting across different packet implementations. The implementation delegates to the standard Debug and Display traits.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;

let disconnect = mqtt::packet::v3_1_1::Disconnect::new();

// Format through the generic trait
println!("{}", disconnect); // Uses fmt_display
println!("{:?}", disconnect); // Uses fmt_debug
Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::Pingreq

Implements the generic packet display trait for PINGREQ packets

This trait provides a common interface for formatting MQTT packets, allowing them to be displayed consistently across different packet types.

§Methods

  • fmt_debug(): Debug formatting
  • fmt_display(): Display formatting
Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::Pingresp

Implements the generic packet display trait for PINGRESP packets

This trait provides a common interface for formatting MQTT packets, allowing them to be displayed consistently across different packet types. It supports both debug and display formatting modes.

§Methods

  • fmt_debug(): Debug formatting (same as Debug trait)
  • fmt_display(): Display formatting (same as Display trait)

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::prelude::*;

let pingresp = mqtt::packet::v3_1_1::Pingresp::new();
let generic_display: &dyn mqtt::packet::GenericPacketDisplay = &pingresp;
println!("{}", format!("{:?}", generic_display));
Source§

impl GenericPacketDisplay for Auth

GenericPacketDisplay implementation for AUTH packets

Implements the generic packet display interface that provides standardized formatting capabilities for AUTH packets. This trait enables consistent display and debug output across different packet types.

Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::Connack

Implementation of GenericPacketDisplay for generic formatting operations

Provides a common interface for formatting operations that can be used generically across different MQTT packet types. This enables uniform display handling in collections and generic contexts.

§Methods

  • fmt_debug(): Delegates to the Debug trait implementation
  • fmt_display(): Delegates to the Display trait implementation

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;
use mqtt_protocol_core::mqtt::result_code::ConnectReasonCode;

let connack = mqtt::packet::v5_0::Connack::builder()
    .session_present(false)
    .reason_code(ConnectReasonCode::Success)
    .build()
    .unwrap();

// Use generic display methods
println!("{}", format_args!("{}", connack)); // Uses fmt_display
Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::Connect

Implements generic packet display behavior for CONNECT packets

This trait provides standardized display formatting methods that work across different MQTT packet types. This allows for uniform handling of packets across different MQTT packet types. This enables uniform display handling in generic packet processing contexts.

§Purpose

Enables consistent display behavior when working with collections of different packet types or in generic packet processing scenarios.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;
use std::fmt::Write;

let connect = mqtt::packet::v5_0::Connect::builder()
    .client_id("display-generic")
    .build()
    .unwrap();

let mut output = String::new();
write!(&mut output, "{}", connect).unwrap();
Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::Disconnect

Implements the generic packet display trait for DISCONNECT packets

This trait provides a common display interface for all MQTT packet types, enabling consistent formatting across different packet implementations.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;

let disconnect = mqtt::packet::v5_0::Disconnect::builder()
    .build()
    .unwrap();

// Format through the generic trait
println!("{}", disconnect);
Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::Pingreq

Implements the generic packet display trait for PINGREQ packets

This trait provides a common interface for formatting MQTT packets, allowing them to be displayed consistently across different packet types.

§Methods

  • fmt_debug(): Debug formatting
  • fmt_display(): Display formatting
Source§

impl GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::Pingresp

Implements the generic packet display trait for PINGRESP packets

This trait provides a common interface for formatting MQTT packets, allowing them to be displayed consistently across different packet types.

§Methods

  • fmt_debug(): Debug formatting
  • fmt_display(): Display formatting
Source§

impl<PacketIdType> GenericPacketDisplay for GenericPacket<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Source§

impl<PacketIdType> GenericPacketDisplay for GenericStorePacket<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPuback<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for GenericPuback.

Provides formatted display capabilities for the PUBACK packet that can be used by the generic packet display system. This enables consistent formatting across all packet types.

§Trait Methods

  • fmt_debug(): Debug formatting (JSON output)
  • fmt_display(): Display formatting (JSON output)
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPubcomp<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for PUBCOMP packets.

This trait provides unified display formatting for all MQTT packet types, enabling consistent output across different packet implementations. Both debug and display formatting produce JSON output for consistency.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::prelude::*;

let pubcomp = mqtt::packet::v3_1_1::Pubcomp::builder()
    .packet_id(1u16)
    .build()
    .unwrap();

// Use generic display interface
println!("{}", pubcomp); // Uses fmt_display
println!("{:?}", pubcomp); // Uses fmt_debug
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for PUBLISH packets

Provides unified display and debug formatting through the generic packet display trait. This enables consistent packet formatting across different packet types in the library.

Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPubrec<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Implementation of GenericPacketDisplay for PUBREC packets.

This trait provides consistent display and debug formatting for PUBREC packets when used in generic packet contexts. It delegates to the standard Display and Debug trait implementations.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::prelude::*;

let pubrec = mqtt::packet::v3_1_1::Pubrec::builder()
    .packet_id(123u16)
    .build()
    .unwrap();

// Use in generic packet display contexts
println!("{}", pubrec); // Uses fmt_display
println!("{:?}", pubrec); // Uses fmt_debug
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPubrel<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Generic packet display trait implementation for PUBREL packets.

This implementation provides generic display formatting capabilities that can be used by the MQTT protocol library framework for consistent packet representation across different display contexts.

§Methods

  • fmt_debug(): Provides debug formatting via the Debug trait
  • fmt_display(): Provides display formatting via the Display trait
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericSuback<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for GenericSuback

Provides standardized display formatting for SUBACK packets through the GenericPacketDisplay trait. This allows consistent formatting across different packet types in the library.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;
use mqtt_protocol_core::mqtt::result_code::SubackReturnCode;

let suback = mqtt::packet::v3_1_1::Suback::builder()
    .packet_id(42u16)
    .return_codes(vec![SubackReturnCode::SuccessMaximumQos1])
    .build()
    .unwrap();

// Use trait methods for consistent formatting
println!("{}", format_args!("{}", suback));
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericSubscribe<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Generic packet display trait implementation for SUBSCRIBE packets

Provides unified display formatting for packet types, supporting both debug and display formatting through a common interface. This is used by the packet handling infrastructure for consistent logging and debugging.

Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericUnsuback<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for GenericUnsuback

Provides standardized display formatting for UNSUBACK packets through the GenericPacketDisplay trait. This allows consistent formatting across different packet types in the library.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;

let unsuback = mqtt::packet::v3_1_1::Unsuback::builder()
    .packet_id(42u16)
    .build()
    .unwrap();

// Use trait methods for consistent formatting
println!("{}", format_args!("{}", unsuback));
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericUnsubscribe<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Generic packet display trait implementation for UNSUBSCRIBE packets

Provides display formatting methods for consistent packet output across the MQTT protocol framework.

Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericPuback<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for GenericPuback.

Provides formatted display capabilities for the PUBACK packet that can be used by the generic packet display system. This enables consistent formatting across all packet types.

§Trait Methods

  • fmt_debug(): Debug formatting (JSON output)
  • fmt_display(): Display formatting (JSON output)
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericPubcomp<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for PUBCOMP packets.

This trait provides unified display formatting for all MQTT packet types, enabling consistent output across different packet implementations.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::prelude::*;

let pubcomp = mqtt::packet::v5_0::Pubcomp::builder()
    .packet_id(1u16)
    .build()
    .unwrap();

// Use generic display interface
println!("{}", pubcomp); // Uses fmt_display
println!("{:?}", pubcomp); // Uses fmt_debug
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Generic packet display trait implementation for PUBLISH packets

Provides the display interface used by the generic packet handling system.

Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericPubrec<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Implementation of GenericPacketDisplay for PUBREC packets.

This trait provides consistent display and debug formatting for PUBREC packets when used in generic packet contexts. It delegates to the standard Display and Debug trait implementations.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::prelude::*;

let pubrec = mqtt::packet::v5_0::Pubrec::builder()
    .packet_id(123u16)
    .build()
    .unwrap();

// Use in generic packet display contexts
println!("{}", pubrec); // Uses fmt_display
println!("{:?}", pubrec); // Uses fmt_debug
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericPubrel<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Generic packet display trait implementation for PUBREL packets.

This implementation provides generic display formatting capabilities that can be used by the MQTT protocol library framework for consistent packet representation across different display contexts.

§Methods

  • fmt_debug(): Provides debug formatting via the Debug trait
  • fmt_display(): Provides display formatting via the Display trait
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericSuback<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for GenericSuback

Provides standardized display formatting for SUBACK packets through the GenericPacketDisplay trait. This allows consistent formatting across different packet types in the library.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;
use mqtt_protocol_core::mqtt::result_code::SubackReasonCode;

let suback = mqtt::packet::v5_0::Suback::builder()
    .packet_id(42u16)
    .reason_codes(vec![SubackReasonCode::GrantedQos1])
    .build()
    .unwrap();

// Use trait methods for consistent formatting
println!("{}", format_args!("{}", suback));
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericSubscribe<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Generic packet display trait implementation for SUBSCRIBE packets

Provides unified display formatting for packet types, supporting both debug and display formatting through a common interface. This is used by the packet handling infrastructure for consistent logging and debugging.

Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericUnsuback<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

GenericPacketDisplay implementation for GenericUnsuback

Provides standardized display formatting for UNSUBACK packets through the GenericPacketDisplay trait. This allows consistent formatting across different packet types in the library.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::GenericPacketDisplay;
use mqtt_protocol_core::mqtt::result_code::UnsubackReasonCode;

let unsuback = mqtt::packet::v5_0::Unsuback::builder()
    .packet_id(42u16)
    .reason_codes(vec![UnsubackReasonCode::Success])
    .build()
    .unwrap();

// Use trait methods for consistent formatting
println!("{}", format_args!("{}", unsuback));
Source§

impl<PacketIdType> GenericPacketDisplay for mqtt_protocol_core::mqtt::packet::v5_0::GenericUnsubscribe<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Generic packet display trait implementation for UNSUBSCRIBE packets

Provides display formatting methods for consistent packet output across the MQTT protocol framework.