ntex_mqtt/v5/codec/
mod.rs1use ntex_bytes::{ByteString, Bytes};
4
5#[allow(clippy::module_inception)]
6mod codec;
7mod decode;
8mod encode;
9mod packet;
10
11pub use self::codec::Codec;
12pub(crate) use self::encode::EncodeLtd;
13pub use self::packet::*;
14
15pub type UserProperty = (ByteString, ByteString);
16pub type UserProperties = Vec<UserProperty>;
17
18#[derive(Clone, PartialEq, Eq)]
19pub enum Decoded {
20 Packet(Packet, u32),
21 Publish(Publish, Bytes, u32),
22 PayloadChunk(Bytes, bool),
23}
24
25#[derive(Clone, Debug, PartialEq, Eq)]
26pub enum Encoded {
27 Packet(Packet),
28 Publish(Publish, Option<Bytes>),
29 PayloadChunk(Bytes),
30}
31
32impl From<Packet> for Encoded {
33 fn from(pkt: Packet) -> Encoded {
34 Encoded::Packet(pkt)
35 }
36}
37
38impl std::fmt::Debug for Decoded {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 match self {
41 Decoded::Packet(pkt, size) => {
42 f.debug_tuple("Decoded::Packet").field(pkt).field(size).finish()
43 }
44 Decoded::Publish(pkt, _, size) => f
45 .debug_tuple("Decoded::Publish")
46 .field(pkt)
47 .field(&"<REDACTED>")
48 .field(size)
49 .finish(),
50 Decoded::PayloadChunk(_, eof) => {
51 f.debug_tuple("Decoded::Publish").field(&"<REDACTED>").field(eof).finish()
52 }
53 }
54 }
55}