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



                                                      
                          
                                                 




                                                      
                            

                        
                                                                               







                                         
                                                  


                                                                        
// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

use crate::xep_0300::Hash;
use peanuts::{Element, FromElement, IntoElement};

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::DeserializeResult<Self> {
        element.check_name("c")?;
        element.check_namespace(XMLNS)?;

        Ok(Self(element.pop_children()?))
    }
}

impl IntoElement for C {
    fn builder(&self) -> peanuts::ElementBuilder {
        Element::builder("c", Some(XMLNS)).push_children(self.0.clone())
    }
}