aboutsummaryrefslogtreecommitdiffstats
path: root/stanza/src/xep_0199.rs
blob: 9605721913a5cfe0abb87dc4de2f4c01407389fb (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 peanuts::{
    element::{FromElement, IntoElement},
    Element,
};

pub const XMLNS: &str = "urn:xmpp:ping";

#[derive(Clone, Copy, Debug)]
pub struct Ping;

impl FromElement for Ping {
    fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> {
        element.check_name("ping")?;
        element.check_namespace(XMLNS)?;

        element.no_more_content()?;

        Ok(Ping)
    }
}

impl IntoElement for Ping {
    fn builder(&self) -> peanuts::element::ElementBuilder {
        Element::builder("ping", Some(XMLNS))
    }
}