aboutsummaryrefslogblamecommitdiffstats
path: root/stanza/src/xep_0390.rs
blob: bcd331dc6ab7d19370d9db44f9aac80183c5c184 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                      
                            














                                                                                        
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(pub 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())
    }
}