jingle_ft: Add a received parser.

This commit is contained in:
Emmanuel Gil Peyrot 2017-04-28 23:43:47 +01:00
parent eeb9b36620
commit de93c32cb5

View file

@ -62,6 +62,26 @@ pub struct Checksum {
pub file: File, pub file: File,
} }
#[derive(Debug, Clone)]
pub struct Received {
pub name: String,
pub creator: Creator,
}
impl IntoElements for Received {
fn into_elements(self, emitter: &mut ElementEmitter) {
let elem = Element::builder("received")
.ns(ns::JINGLE_FT)
.attr("name", self.name)
.attr("creator", match self.creator {
Creator::Initiator => "initiator",
Creator::Responder => "responder",
})
.build();
emitter.append_child(elem);
}
}
pub fn parse_jingle_ft(root: &Element) -> Result<Description, Error> { pub fn parse_jingle_ft(root: &Element) -> Result<Description, Error> {
if !root.is("description", ns::JINGLE_FT) { if !root.is("description", ns::JINGLE_FT) {
return Err(Error::ParseError("This is not a JingleFT description element.")); return Err(Error::ParseError("This is not a JingleFT description element."));