1use std::str::Utf8Error;
2
3pub mod v5;
6
7pub use mqttbytes_core::{QoS, has_wildcards, matches, qos, valid_filter, valid_topic};
8
9#[derive(Debug, thiserror::Error)]
11pub enum Error {
12 #[error("Invalid return code received as response for connect = {0}")]
13 InvalidConnectReturnCode(u8),
14 #[error("Invalid reason = {0}")]
15 InvalidReason(u8),
16 #[error("Invalid remaining length = {0}")]
17 InvalidRemainingLength(usize),
18 #[error("Invalid protocol used")]
19 InvalidProtocol,
20 #[error("Invalid protocol level")]
21 InvalidProtocolLevel(u8),
22 #[error("Invalid packet format")]
23 IncorrectPacketFormat,
24 #[error("Invalid packet type = {0}")]
25 InvalidPacketType(u8),
26 #[error("Invalid retain forward rule = {0}")]
27 InvalidRetainForwardRule(u8),
28 #[error("Invalid QoS level = {0}")]
29 InvalidQoS(u8),
30 #[error("Invalid subscribe reason code = {0}")]
31 InvalidSubscribeReasonCode(u8),
32 #[error("Packet received has id Zero")]
33 PacketIdZero,
34 #[error("Empty Subscription")]
35 EmptySubscription,
36 #[error("Packet violates the MQTT protocol")]
37 ProtocolError,
38 #[error("Packet violates the MQTT protocol with disconnect reason {0:?}")]
39 ProtocolViolation(v5::DisconnectReasonCode),
40 #[error("Payload size is incorrect")]
41 PayloadSizeIncorrect,
42 #[error("Payload is too long")]
43 PayloadTooLong,
44 #[error("Max Payload size of {max:?} has been exceeded by packet of {pkt_size:?} bytes")]
45 PayloadSizeLimitExceeded { pkt_size: usize, max: u32 },
46 #[error("Payload is required")]
47 PayloadRequired,
48 #[error("Payload is required = {0}")]
49 PayloadNotUtf8(#[from] Utf8Error),
50 #[error("Topic not utf-8")]
51 TopicNotUtf8,
52 #[error("Promised boundary crossed, contains {0} bytes")]
53 BoundaryCrossed(usize),
54 #[error("Packet is malformed")]
55 MalformedPacket,
56 #[error("Remaining length is malformed")]
57 MalformedRemainingLength,
58 #[error("Invalid property type = {0}")]
59 InvalidPropertyType(u8),
60 #[error("Insufficient number of bytes to frame packet, {0} more bytes required")]
64 InsufficientBytes(usize),
65 #[error("IO: {0}")]
66 Io(#[from] std::io::Error),
67 #[error(
68 "Cannot send packet of size '{pkt_size:?}'. It's greater than the broker's maximum packet size of: '{max:?}'"
69 )]
70 OutgoingPacketTooLarge { pkt_size: u32, max: u32 },
71}