blob: 0f4b29833207318a1a74ea862f5d919373285bb4 (
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
32
33
34
35
|
// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
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"))
}
}
|