blob: a05a6591848211c21338efa0f4327ee4c2d14fbf (
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
|
use crate::xep_0300::Hash;
use peanuts::{
element::{FromElement, IntoElement},
Element,
};
pub const XMLNS: &str = "urn:xmpp:caps";
// TODO: have a vec which guarantees at least one item
#[derive(Debug, Clone)]
pub struct C(Vec<Hash>);
impl FromElement for C {
fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> {
element.check_name("c")?;
element.check_namespace(XMLNS)?;
Ok(Self(element.pop_children()?))
}
}
impl IntoElement for C {
fn builder(&self) -> peanuts::element::ElementBuilder {
Element::builder("c", Some(XMLNS)).push_children(self.0.clone())
}
}
|