blob: 41ff196d1708f67c22760e1c2c641b00f068401c (
plain) (
blame)
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
|
use chrono::{DateTime, Utc};
use jid::JID;
use peanuts::{Element, FromElement, IntoElement};
pub const XMLNS: &str = "urn:xmpp:delay";
#[derive(Debug, Clone)]
pub struct Delay {
pub from: Option<JID>,
pub stamp: DateTime<Utc>,
}
impl FromElement for Delay {
fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> {
element.check_name("delay")?;
element.check_namespace(XMLNS)?;
let from = element.attribute_opt("from")?;
let stamp = element.attribute("stamp")?;
Ok(Delay { from, stamp })
}
}
impl IntoElement for Delay {
fn builder(&self) -> peanuts::ElementBuilder {
Element::builder("delay", Some(XMLNS))
.push_attribute_opt("from", self.from.clone())
.push_attribute("stamp", self.stamp.format("%C%y-%m-%dT%H:%M:%S%.3f%:z"))
}
}
|