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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
use peanuts::{Element, FromElement, IntoElement};
use crate::xep_0297::Forwarded;
pub const XMLNS: &str = "urn:xmpp:carbons:2";
#[derive(Clone, Debug)]
pub struct Disable;
impl FromElement for Disable {
fn from_element(element: Element) -> peanuts::DeserializeResult<Self> {
element.check_name("disable")?;
element.check_namespace(XMLNS)?;
element.no_more_content()?;
Ok(Self)
}
}
impl IntoElement for Disable {
fn builder(&self) -> peanuts::ElementBuilder {
Element::builder("disable", Some(XMLNS))
}
}
#[derive(Clone, Debug)]
pub struct Enable;
impl FromElement for Enable {
fn from_element(element: Element) -> peanuts::DeserializeResult<Self> {
element.check_name("enable")?;
element.check_namespace(XMLNS)?;
element.no_more_content()?;
Ok(Self)
}
}
impl IntoElement for Enable {
fn builder(&self) -> peanuts::ElementBuilder {
Element::builder("enable", Some(XMLNS))
}
}
#[derive(Clone, Debug)]
pub struct Private;
impl FromElement for Private {
fn from_element(element: Element) -> peanuts::DeserializeResult<Self> {
element.check_name("private")?;
element.check_namespace(XMLNS)?;
element.no_more_content()?;
Ok(Self)
}
}
impl IntoElement for Private {
fn builder(&self) -> peanuts::ElementBuilder {
Element::builder("private", Some(XMLNS))
}
}
#[derive(Clone, Debug)]
pub struct Received {
forwarded: Forwarded,
}
impl FromElement for Received {
fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> {
element.check_name("received")?;
element.check_namespace(XMLNS)?;
let forwarded = element.pop_child_one()?;
Ok(Self { forwarded })
}
}
impl IntoElement for Received {
fn builder(&self) -> peanuts::ElementBuilder {
Element::builder("received", Some(XMLNS)).push_child(self.forwarded.clone())
}
}
#[derive(Clone, Debug)]
pub struct Sent {
forwarded: Forwarded,
}
impl FromElement for Sent {
fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> {
element.check_name("sent")?;
element.check_namespace(XMLNS)?;
let forwarded = element.pop_child_one()?;
Ok(Self { forwarded })
}
}
impl IntoElement for Sent {
fn builder(&self) -> peanuts::ElementBuilder {
Element::builder("sent", Some(XMLNS)).push_child(self.forwarded.clone())
}
}
|