Coverage for src / zmqtt / _internal / packets / publish.py: 100%
30 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-11-12 08:49 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-11-12 08:49 +0000
1from dataclasses import dataclass
2from typing import ClassVar
4from zmqtt._internal.packets.properties import PubAckProperties, PublishProperties
5from zmqtt._internal.packets.types import Packet, PacketType
6from zmqtt._internal.types.qos import QoS
9@dataclass(frozen=True, slots=True, kw_only=True)
10class Publish(Packet):
11 packet_type: ClassVar[PacketType] = PacketType.PUBLISH
13 topic: str
14 payload: bytes
15 qos: QoS
16 retain: bool
17 dup: bool
18 packet_id: int | None = None # required for QoS 1 and 2
19 properties: PublishProperties | None = None # v5 only
22@dataclass(frozen=True, slots=True, kw_only=True)
23class PubAck(Packet):
24 packet_type: ClassVar[PacketType] = PacketType.PUBACK
26 packet_id: int
27 reason_code: int = 0 # v5 only; 0 = success
28 properties: PubAckProperties | None = None # v5 only
31@dataclass(frozen=True, slots=True, kw_only=True)
32class PubRec(Packet):
33 packet_type: ClassVar[PacketType] = PacketType.PUBREC
35 packet_id: int
36 reason_code: int = 0 # v5 only; 0 = success
37 properties: PubAckProperties | None = None # v5 only
40@dataclass(frozen=True, slots=True, kw_only=True)
41class PubRel(Packet):
42 packet_type: ClassVar[PacketType] = PacketType.PUBREL
44 packet_id: int
45 reason_code: int = 0 # v5 only; 0 = success
46 properties: PubAckProperties | None = None # v5 only
49@dataclass(frozen=True, slots=True, kw_only=True)
50class PubComp(Packet):
51 packet_type: ClassVar[PacketType] = PacketType.PUBCOMP
53 packet_id: int
54 reason_code: int = 0 # v5 only; 0 = success
55 properties: PubAckProperties | None = None # v5 only