GenericPublish

Struct GenericPublish 

Source
pub struct GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,
{ pub props: Properties, /* private fields */ }
Expand description

MQTT 5.0 PUBLISH packet representation

The PUBLISH packet is used to transport application messages from a client to the server or from the server to a client. It is the primary packet type for delivering messages in MQTT and supports Quality of Service (QoS) levels 0, 1, and 2.

According to MQTT 5.0 specification, the PUBLISH packet contains:

  • Fixed header with packet type, flags (DUP, QoS, RETAIN), and remaining length
  • Variable header with topic name, packet identifier (for QoS > 0), and properties
  • Payload containing the application message data

§Fixed Header Flags

The PUBLISH packet uses the following fixed header flags:

  • Bit 0: RETAIN flag - if set, the server retains the message for future subscribers
  • Bits 1-2: QoS level (0, 1, or 2) - determines delivery guarantee
  • Bit 3: DUP flag - indicates this is a duplicate message (QoS > 0 only)
  • Bits 4-7: Packet type (0011 for PUBLISH)

§Quality of Service (QoS)

  • QoS 0: At most once delivery - fire and forget, no packet identifier required
  • QoS 1: At least once delivery - requires packet identifier and PUBACK response
  • QoS 2: Exactly once delivery - requires packet identifier and PUBREC/PUBREL/PUBCOMP sequence

§Topic Names and Topic Aliases

MQTT 5.0 introduces Topic Aliases to reduce packet size for frequently used topics. The topic name can be replaced with a numeric alias after the first use, allowing for more efficient transmission of messages on the same topic.

§Properties

MQTT 5.0 PUBLISH packets can include various properties:

  • Payload Format Indicator - indicates if payload is UTF-8 text or binary
  • Message Expiry Interval - message expiration time in seconds
  • Topic Alias - numeric alias for the topic name
  • Response Topic - topic for response messages
  • Correlation Data - correlation data for request/response flows
  • User Properties - custom key-value pairs
  • Subscription Identifier - identifier matching subscription (server to client only)
  • Content Type - MIME type of the payload

§Generic Type Parameter

The PacketIdType generic parameter allows using packet identifiers larger than the standard u16, which can be useful for broker clusters to avoid packet ID exhaustion when extending the MQTT protocol.

§Examples

use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::qos::Qos;

// Create a simple QoS 0 PUBLISH message
let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("sensor/temperature")
    .unwrap()
    .qos(Qos::AtMostOnce)
    .payload(b"23.5")
    .build()
    .unwrap();

assert_eq!(publish.topic_name(), "sensor/temperature");
assert_eq!(publish.qos(), Qos::AtMostOnce);
assert_eq!(publish.payload().as_slice(), b"23.5");
assert!(!publish.retain());
assert!(!publish.dup());
assert_eq!(publish.packet_id(), None);

// Create a QoS 1 PUBLISH message with retain flag
let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("device/status")
    .unwrap()
    .qos(Qos::AtLeastOnce)
    .packet_id(123)
    .retain(true)
    .payload(b"online")
    .build()
    .unwrap();

assert_eq!(publish.qos(), Qos::AtLeastOnce);
assert!(publish.retain());
assert_eq!(publish.packet_id(), Some(123));

// Serialize to bytes for network transmission
let buffers = publish.to_buffers();
let total_size = publish.size();

Fields§

§props: Properties

Implementations§

Source§

impl<PacketIdType> GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source

pub fn props(&self) -> &Properties

Source§

impl<PacketIdType> GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source§

impl<PacketIdType> GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source

pub fn builder() -> GenericPublishBuilder<PacketIdType>

Creates a new builder for constructing a PUBLISH packet

The builder pattern allows for flexible construction of PUBLISH packets with various combinations of properties, QoS levels, and content.

§Returns

A GenericPublishBuilder instance with default values

§Examples
use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::qos::Qos;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("sensors/temperature")
    .unwrap()
    .qos(Qos::AtLeastOnce)
    .packet_id(1)
    .retain(true)
    .payload(b"25.3")
    .build()
    .unwrap();
Source

pub fn packet_type() -> PacketType

Returns the packet type for PUBLISH packets

This is always PacketType::Publish for PUBLISH packet instances.

§Returns

PacketType::Publish

§Examples
use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::packet_type::PacketType;

assert_eq!(mqtt::packet::v5_0::Publish::packet_type(), PacketType::Publish);
Source

pub fn packet_id(&self) -> Option<PacketIdType>

Returns the packet identifier if present

The packet identifier is only present for QoS 1 and QoS 2 PUBLISH packets. For QoS 0 packets, this method returns None.

§Returns
  • Some(PacketIdType) - The packet identifier for QoS > 0 packets
  • None - For QoS 0 packets
§Examples
use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::qos::Qos;

// QoS 0 packet has no packet ID
let qos0_publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("topic")
    .unwrap()
    .qos(Qos::AtMostOnce)
    .build()
    .unwrap();
assert_eq!(qos0_publish.packet_id(), None);

// QoS 1 packet has packet ID
let qos1_publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("topic")
    .unwrap()
    .qos(Qos::AtLeastOnce)
    .packet_id(42)
    .build()
    .unwrap();
assert_eq!(qos1_publish.packet_id(), Some(42));
Source

pub fn qos(&self) -> Qos

Returns the Quality of Service level for this PUBLISH packet

The QoS level determines the delivery guarantee for the message:

  • QoS 0: At most once delivery (fire and forget)
  • QoS 1: At least once delivery (acknowledged)
  • QoS 2: Exactly once delivery (assured)
§Returns

The Qos level extracted from the fixed header flags

§Examples
use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::qos::Qos;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("topic")
    .unwrap()
    .qos(Qos::ExactlyOnce)
    .packet_id(1)
    .build()
    .unwrap();

assert_eq!(publish.qos(), Qos::ExactlyOnce);
Source

pub fn dup(&self) -> bool

Returns the DUP (duplicate) flag status

The DUP flag indicates whether this PUBLISH packet is a duplicate of an earlier packet that may not have been acknowledged. This flag is only meaningful for QoS 1 and QoS 2 packets and should be ignored for QoS 0 packets.

§Returns
  • true if this is a duplicate packet
  • false if this is the first transmission attempt
§Examples
use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::qos::Qos;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("topic")
    .unwrap()
    .qos(Qos::AtLeastOnce)
    .packet_id(1)
    .dup(true)
    .build()
    .unwrap();

assert!(publish.dup());
Source

pub fn retain(&self) -> bool

Returns the RETAIN flag status

The RETAIN flag indicates whether the server should retain this message for future subscribers to the topic. When a client subscribes to a topic with a retained message, it will immediately receive the retained message.

§Returns
  • true if the message should be retained by the server
  • false if the message should not be retained
§Examples
use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::qos::Qos;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("device/status")
    .unwrap()
    .qos(Qos::AtMostOnce)
    .retain(true)
    .payload(b"online")
    .build()
    .unwrap();

assert!(publish.retain());
Source

pub fn set_dup(self, dup: bool) -> Self

Sets the DUP (duplicate) flag and returns the modified packet

This method is typically used when retransmitting a QoS 1 or QoS 2 PUBLISH packet that may not have been acknowledged. The DUP flag helps the receiver identify potential duplicate messages.

§Parameters
  • dup: Whether to set the DUP flag (true) or clear it (false)
§Returns

The modified GenericPublish instance with the DUP flag updated

§Examples
use mqtt_protocol_core::mqtt;
use mqtt_protocol_core::mqtt::packet::qos::Qos;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("topic")
    .unwrap()
    .qos(Qos::AtLeastOnce)
    .packet_id(1)
    .build()
    .unwrap();

assert!(!publish.dup());

let dup_publish = publish.set_dup(true);
assert!(dup_publish.dup());
Source

pub fn topic_name(&self) -> &str

Returns the topic name for this PUBLISH packet

The topic name identifies the information channel to which the payload is published. In MQTT 5.0, the topic name may be empty if a TopicAlias property is used instead.

§Returns

A string slice containing the topic name

§Examples
use mqtt_protocol_core::mqtt;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("sensors/temperature/room1")
    .unwrap()
    .build()
    .unwrap();

assert_eq!(publish.topic_name(), "sensors/temperature/room1");
Source

pub fn payload(&self) -> &ArcPayload

Returns a reference to the payload data

The payload contains the application message data being published. It can be any binary data up to the maximum message size allowed by the MQTT implementation.

§Returns

A reference to the ArcPayload containing the message data

§Examples
use mqtt_protocol_core::mqtt;

let message_data = b"Hello, MQTT World!";
let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("greetings")
    .unwrap()
    .payload(message_data)
    .build()
    .unwrap();

assert_eq!(publish.payload().as_slice(), message_data);
assert_eq!(publish.payload().len(), message_data.len());
Source

pub fn remove_topic_alias_add_topic( self, topic: String, ) -> Result<Self, MqttError>

Remove TopicAlias property and add topic name

This method is used for store regulation - it sets the topic name and removes any TopicAlias property from the packet properties. This is typically done when storing messages where the topic alias needs to be resolved to the actual topic name for persistence.

The method validates that the current topic name is empty (as expected when using topic aliases) and that the new topic name doesn’t contain wildcard characters, which are not allowed in PUBLISH packets.

§Parameters
  • topic: The topic name to set, replacing any topic alias
§Returns
  • Ok(Self) - The modified packet with topic name set and topic alias removed
  • Err(MqttError) - If the topic name is invalid or the packet state is incorrect
§Errors
  • MqttError::TopicNameInvalid - If the current topic name is not empty
  • MqttError::MalformedPacket - If the topic contains wildcard characters
§Examples
use mqtt_protocol_core::mqtt;

// Assume we have a publish packet with a topic alias
let publish_with_alias = // ... created with topic alias

let publish_with_topic = publish_with_alias
    .remove_topic_alias_add_topic("sensors/temperature".to_string())
    .unwrap();

assert_eq!(publish_with_topic.topic_name(), "sensors/temperature");
// Topic alias property has been removed from properties
Source

pub fn remove_topic_alias(self) -> Self

Remove TopicAlias property

This method removes any TopicAlias property from the packet properties while keeping the topic name unchanged. This is useful when you want to send a packet with the full topic name instead of using a topic alias, or when converting packets for systems that don’t support topic aliases.

The method automatically recalculates the property_length and remaining_length to reflect the removal of the TopicAlias property.

§Returns

The modified GenericPublish instance with TopicAlias property removed

§Examples
use mqtt_protocol_core::mqtt;

// Assume we have a publish packet with both topic name and topic alias
let publish_with_alias = // ... created with topic alias

let publish_without_alias = publish_with_alias.remove_topic_alias();

// Topic name remains the same, but TopicAlias property is removed
assert_eq!(publish_without_alias.topic_name(), "sensors/temperature");
// props() no longer contains TopicAlias property
Source

pub fn add_extracted_topic_name(self, topic: &str) -> Result<Self, MqttError>

Add extracted topic name for TopicAlias resolution

This method is used during packet reception to restore topic names from TopicAlias mappings. It’s typically called by connection handling code when a PUBLISH packet is received with a TopicAlias property but no topic name.

The method requires the current topic name to be empty (as expected when receiving a packet with only a topic alias) and validates that the resolved topic name doesn’t contain wildcard characters. It keeps the TopicAlias property intact and marks the topic name as extracted.

§Parameters
  • topic: The resolved topic name from the topic alias mapping
§Returns
  • Ok(Self) - The modified packet with topic name set and extraction flag marked
  • Err(MqttError) - If the topic name is invalid or the packet state is incorrect
§Errors
  • MqttError::TopicNameInvalid - If the current topic name is not empty
  • MqttError::MalformedPacket - If the topic contains wildcard characters
§Examples
use mqtt_protocol_core::mqtt;

// Assume we received a packet with topic alias but no topic name
let publish_with_alias_only = // ... received packet

let publish_with_extracted_topic = publish_with_alias_only
    .add_extracted_topic_name("sensors/temperature".to_string())
    .unwrap();

assert_eq!(publish_with_extracted_topic.topic_name(), "sensors/temperature");
assert!(publish_with_extracted_topic.topic_name_extracted());
Source

pub fn remove_topic_add_topic_alias(self, topic_alias: u16) -> Self

Remove topic name and add TopicAlias property

This method replaces the topic name with a TopicAlias property, setting the topic name to an empty string and adding the TopicAlias property to the packet properties. This is useful for reducing packet size when sending multiple messages to the same topic.

The method removes any existing TopicAlias property before adding the new one to ensure only one TopicAlias property exists. It automatically recalculates the property_length and remaining_length to reflect these changes.

§Parameters
  • topic_alias: The numeric topic alias to use instead of the topic name
§Returns

The modified GenericPublish instance with empty topic name and TopicAlias property

§Examples
use mqtt_protocol_core::mqtt;

let publish_with_topic = mqtt::packet::v5_0::Publish::builder()
    .topic_name("sensors/temperature/room1")
    .unwrap()
    .payload(b"23.5")
    .build()
    .unwrap();

let publish_with_alias = publish_with_topic.remove_topic_add_topic_alias(42);

assert_eq!(publish_with_alias.topic_name(), "");
// props() now contains TopicAlias property with value 42
Source

pub fn size(&self) -> usize

Returns the total size of the PUBLISH packet in bytes

This includes the fixed header, variable header, and payload. The size calculation accounts for:

  • Fixed header (1 byte)
  • Remaining length field (1-4 bytes)
  • All variable header and payload data
§Returns

The total packet size in bytes

§Examples
use mqtt_protocol_core::mqtt;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("test")
    .unwrap()
    .payload(b"hello")
    .build()
    .unwrap();

let packet_size = publish.size();
println!("PUBLISH packet size: {} bytes", packet_size);
Source

pub fn to_buffers(&self) -> Vec<IoSlice<'_>>

Converts the PUBLISH packet to a vector of I/O slices for efficient transmission

This method creates a vector of IoSlice references that can be used with vectored I/O operations (like write_vectored) for efficient network transmission without copying the packet data.

The buffers are arranged in the correct MQTT packet order:

  1. Fixed header
  2. Remaining length
  3. Topic name
  4. Packet identifier (if QoS > 0)
  5. Property length
  6. Properties
  7. Payload
§Returns

A vector of IoSlice references representing the complete packet

§Examples
use mqtt_protocol_core::mqtt;
use std::io::Write;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("test/topic")
    .unwrap()
    .payload(b"test payload")
    .build()
    .unwrap();

let buffers = publish.to_buffers();
// Use with vectored I/O: stream.write_vectored(&buffers)
Source

pub fn to_continuous_buffer(&self) -> Vec<u8>

Create a continuous buffer containing the complete packet data

Returns a vector containing all packet bytes in a single continuous buffer. This method is compatible with no-std environments and provides an alternative to to_buffers() when vectored I/O is not needed.

The returned buffer contains the complete PUBLISH packet serialized according to the MQTT v5.0 protocol specification, including fixed header, remaining length, topic name, packet identifier, properties, and payload.

§Returns

A vector containing the complete packet data

§Examples
use mqtt_protocol_core::mqtt;

let publish = mqtt::packet::v5_0::Publish::builder()
    .topic_name("sensors/temperature")
    .qos(mqtt::qos::QualityOfService::AtLeastOnce)
    .packet_id(1u16)
    .payload(b"23.5")
    .build()
    .unwrap();

let buffer = publish.to_continuous_buffer();
// buffer contains all packet bytes
Source

pub fn parse(flags: u8, data_arc: Arc<[u8]>) -> Result<(Self, usize), MqttError>

Parses a PUBLISH packet from raw bytes

This method deserializes PUBLISH packet data from a byte buffer, validating the packet structure and extracting all components including topic name, packet identifier, properties, and payload.

The parsing process:

  1. Validates QoS flags (QoS 3 is invalid)
  2. Extracts topic name
  3. Extracts packet identifier (if QoS > 0)
  4. Parses properties (if present)
  5. Extracts payload (remaining bytes)
  6. Validates property constraints
§Parameters
  • flags: The fixed header flags byte containing QoS, DUP, and RETAIN flags
  • data_arc: Shared reference to the packet data bytes
§Returns
  • Ok((GenericPublish, usize)) - The parsed packet and total bytes consumed
  • Err(MqttError) - If the packet is malformed or invalid
§Errors
  • MqttError::MalformedPacket - If QoS is 3, insufficient data, or invalid structure
  • MqttError::ProtocolError - If properties are invalid for PUBLISH packets
§Examples
use mqtt_protocol_core::mqtt;
use alloc::sync::Arc;

let packet_data: Arc<[u8]> = // ... raw packet bytes
let flags = 0x00; // QoS 0, no DUP, no RETAIN

match mqtt::packet::v5_0::Publish::parse(flags, packet_data) {
    Ok((publish, consumed)) => {
        println!("Parsed PUBLISH: topic={}, payload_len={}",
                 publish.topic_name(), publish.payload().len());
    }
    Err(e) => println!("Parse error: {:?}", e),
}

Trait Implementations§

Source§

impl<PacketIdType> Clone for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + Clone, PacketIdType::Buffer: Clone,

Source§

fn clone(&self) -> GenericPublish<PacketIdType>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<PacketIdType> Debug for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Debug trait implementation for PUBLISH packets

Uses the same JSON representation as Display for consistent debugging output.

Source§

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

Formats the PUBLISH packet for debug output

Delegates to the Display implementation for consistent output format.

§Parameters
  • f: The formatter to write to
§Returns

Formatting result with JSON representation

Source§

impl<PacketIdType> Display for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Display trait implementation for PUBLISH packets

Provides human-readable JSON string representation of PUBLISH packets using the Serialize implementation.

Source§

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

Formats the PUBLISH packet as a JSON string

§Parameters
  • f: The formatter to write to
§Returns

Formatting result with JSON representation or error message

Source§

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

Source§

fn from(v: GenericPublish<PacketIdType>) -> GenericPacket<PacketIdType>

Converts to this type from the input type.
Source§

impl<PacketIdType> GenericPacketDisplay for 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§

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

Formats the packet for debug display

§Parameters
  • f: The formatter to write to
§Returns

Formatting result

Source§

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

Formats the packet for display

§Parameters
  • f: The formatter to write to
§Returns

Formatting result

Source§

impl<PacketIdType> GenericPacketTrait for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Generic packet trait implementation for PUBLISH packets

Provides the common packet interface used by the MQTT protocol implementation for size calculation and buffer generation.

Source§

fn size(&self) -> usize

Returns the total packet size in bytes

Delegates to the packet’s own size method.

§Returns

Total packet size including all headers and payload

Source§

fn to_buffers(&self) -> Vec<IoSlice<'_>>

Converts to I/O slices for efficient transmission

Delegates to the packet’s own to_buffers method.

§Returns

Vector of I/O slices representing the complete packet

Source§

fn to_continuous_buffer(&self) -> Vec<u8>

Create a continuous buffer containing the complete packet data Read more
Source§

impl<PacketIdType> PacketKind for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBLISH: bool = true

true if this is a PUBLISH packet
Source§

const IS_V5_0: bool = true

true if this is an MQTT v5.0 packet
Source§

const IS_CONNECT: bool = false

true if this is a CONNECT packet
Source§

const IS_CONNACK: bool = false

true if this is a CONNACK packet
Source§

const IS_PUBACK: bool = false

true if this is a PUBACK packet
Source§

const IS_PUBREC: bool = false

true if this is a PUBREC packet
Source§

const IS_PUBREL: bool = false

true if this is a PUBREL packet
Source§

const IS_PUBCOMP: bool = false

true if this is a PUBCOMP packet
Source§

const IS_SUBSCRIBE: bool = false

true if this is a SUBSCRIBE packet
Source§

const IS_SUBACK: bool = false

true if this is a SUBACK packet
Source§

const IS_UNSUBSCRIBE: bool = false

true if this is an UNSUBSCRIBE packet
Source§

const IS_UNSUBACK: bool = false

true if this is an UNSUBACK packet
Source§

const IS_PINGREQ: bool = false

true if this is a PINGREQ packet
Source§

const IS_PINGRESP: bool = false

true if this is a PINGRESP packet
Source§

const IS_DISCONNECT: bool = false

true if this is a DISCONNECT packet
Source§

const IS_AUTH: bool = false

true if this is an AUTH packet (v5.0 only)
Source§

const IS_V3_1_1: bool = false

true if this is an MQTT v3.1.1 packet
Source§

impl<PacketIdType> PartialEq for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + PartialEq, PacketIdType::Buffer: PartialEq,

Source§

fn eq(&self, other: &GenericPublish<PacketIdType>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<PacketIdType> Serialize for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

Serde serialization implementation for PUBLISH packets

Provides JSON serialization support for PUBLISH packets, converting all packet fields to a structured JSON representation. Binary payload data is handled appropriately with escape sequences when necessary.

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes the PUBLISH packet to the given serializer

Creates a structured representation including packet type, topic name, QoS level, flags, packet identifier, properties, and payload data. Binary payload data is escaped appropriately for JSON representation.

§Parameters
  • serializer: The serde serializer to write to
§Returns

Serializer result containing the serialized packet data

Source§

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

Source§

type Error = MqttError

The type returned in the event of a conversion error.
Source§

fn try_from(publish: GenericPublish<PacketIdType>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

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

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<GenericPublish<PacketIdType>, <Self as TryInto<GenericPublish<PacketIdType>>>::Error>

Performs the conversion.
Source§

impl<PacketIdType> Eq for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + Eq, PacketIdType::Buffer: Eq,

Source§

impl<PacketIdType> SendableRole<Any> for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source§

impl<PacketIdType> SendableRole<Client> for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source§

impl<PacketIdType> SendableRole<Server> for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source§

impl<PacketIdType> StructuralPartialEq for GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Auto Trait Implementations§

§

impl<PacketIdType> Freeze for GenericPublish<PacketIdType>
where <PacketIdType as IsPacketId>::Buffer: Freeze,

§

impl<PacketIdType> RefUnwindSafe for GenericPublish<PacketIdType>
where <PacketIdType as IsPacketId>::Buffer: RefUnwindSafe,

§

impl<PacketIdType> Send for GenericPublish<PacketIdType>
where <PacketIdType as IsPacketId>::Buffer: Send,

§

impl<PacketIdType> Sync for GenericPublish<PacketIdType>
where <PacketIdType as IsPacketId>::Buffer: Sync,

§

impl<PacketIdType> Unpin for GenericPublish<PacketIdType>
where <PacketIdType as IsPacketId>::Buffer: Unpin,

§

impl<PacketIdType> UnwindSafe for GenericPublish<PacketIdType>
where <PacketIdType as IsPacketId>::Buffer: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Role, PacketIdType, T> Sendable<Role, PacketIdType> for T
where Role: RoleType, PacketIdType: IsPacketId, T: SendableRole<Role> + SendableVersion + Display + Debug + PacketKind + SendableHelper<Role, PacketIdType>,

Source§

fn dispatch_send( self, connection: &mut GenericConnection<Role, PacketIdType>, ) -> Vec<GenericEvent<PacketIdType>>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.