diff --git a/src/ibb.rs b/src/ibb.rs index 6811e68c..f77541c8 100644 --- a/src/ibb.rs +++ b/src/ibb.rs @@ -37,7 +37,7 @@ impl FromStr for Stanza { pub enum IBB { Open { block_size: u16, sid: String, stanza: Stanza }, Data { seq: u16, sid: String, data: Vec }, - Close(String), + Close { sid: String }, } fn optional_attr(root: &Element, attr: &str) -> Option { @@ -76,6 +76,14 @@ pub fn parse_ibb(root: &Element) -> Result { sid: sid, data: data }) + } else if root.is("close", ns::IBB) { + let sid = required_attr(root, "sid", Error::ParseError("Required attribute 'sid' missing in data element."))?; + for _ in root.children() { + return Err(Error::ParseError("Unknown child in close element.")); + } + Ok(IBB::Close { + sid: sid, + }) } else { Err(Error::ParseError("This is not an ibb element.")) } @@ -94,6 +102,9 @@ mod tests { let elem: Element = "AAAA".parse().unwrap(); ibb::parse_ibb(&elem).unwrap(); + + let elem: Element = "".parse().unwrap(); + ibb::parse_ibb(&elem).unwrap(); } #[test]