blob: 54fc20b1296815e18c2eef6d05843cc4070eabec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
use yoke::Yoke;
use super::MqttPacket;
use super::StableBytes;
crate::properties::define_properties! {
properties_type: mqtt_format::v5::packets::puback::PubackProperties,
anker: "_Toc3901125",
pub struct PubackProperties {
(anker: "_Toc3901127")
reason_string: ReasonString<'i> with setter = String,
(anker: "_Toc3901128")
user_properties: UserProperties<'i> with setter = crate::properties::UserProperty,
}
}
#[derive(Clone, Debug)]
pub struct Puback {
packet: Yoke<mqtt_format::v5::packets::puback::MPuback<'static>, StableBytes>,
}
impl Puback {
pub(crate) fn get(&self) -> &mqtt_format::v5::packets::puback::MPuback<'_> {
self.packet.get()
}
}
impl TryFrom<MqttPacket> for Puback {
type Error = ();
fn try_from(value: MqttPacket) -> Result<Self, Self::Error> {
let packet = value.packet.try_map_project(|p, _| match p {
mqtt_format::v5::packets::MqttPacket::Puback(puback) => Ok(puback),
_ => Err(()),
})?;
Ok(Puback { packet })
}
}
|