diff --git a/parsers/src/jingle_ibb.rs b/parsers/src/jingle_ibb.rs index ecc5a904..92d76195 100644 --- a/parsers/src/jingle_ibb.rs +++ b/parsers/src/jingle_ibb.rs @@ -4,22 +4,28 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use crate::ibb::{Stanza, StreamId}; +use xso::{AsXml, FromXml}; + +use crate::ibb::{Stanza, StreamId}; +use crate::ns; -generate_element!( /// Describes an [In-Band Bytestream](https://xmpp.org/extensions/xep-0047.html) /// Jingle transport, see also the [IBB module](../ibb.rs). -Transport, "transport", JINGLE_IBB, -attributes: [ +#[derive(FromXml, AsXml, PartialEq, Debug, Clone)] +#[xml(namespace = ns::JINGLE_IBB, name = "transport")] +pub struct Transport { /// Maximum size in bytes for each chunk. - block_size: Required = "block-size", + #[xml(attribute(name = "block-size"))] + pub block_size: u16, /// The identifier to be used to create a stream. - sid: Required = "sid", + #[xml(attribute)] + pub sid: StreamId, /// Which stanza type to use to exchange data. - stanza: Default = "stanza", -]); + #[xml(attribute(default))] + pub stanza: Stanza, +} #[cfg(test)] mod tests { @@ -61,7 +67,10 @@ mod tests { FromElementError::Invalid(Error::Other(string)) => string, _ => panic!(), }; - assert_eq!(message, "Required attribute 'block-size' missing."); + assert_eq!( + message, + "Required attribute field 'block_size' on Transport element missing." + ); let elem: Element = "" @@ -104,7 +113,10 @@ mod tests { FromElementError::Invalid(Error::Other(string)) => string, _ => panic!(), }; - assert_eq!(message, "Required attribute 'sid' missing."); + assert_eq!( + message, + "Required attribute field 'sid' on Transport element missing." + ); } #[test]