xmpp-parsers: Convert OOB to xso
This commit is contained in:
parent
79e224a02a
commit
f049e3626b
1 changed files with 15 additions and 11 deletions
|
|
@ -4,19 +4,23 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// 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/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
use xso::{AsXml, FromXml};
|
||||||
|
|
||||||
use crate::message::MessagePayload;
|
use crate::message::MessagePayload;
|
||||||
|
use crate::ns;
|
||||||
|
|
||||||
generate_element!(
|
/// Defines associated out of band url.
|
||||||
/// Defines associated out of band url.
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||||
Oob, "x", OOB,
|
#[xml(namespace = ns::OOB, name = "x")]
|
||||||
children: [
|
pub struct Oob {
|
||||||
/// The associated URL.
|
/// The associated URL.
|
||||||
url: Required<String> = ("url", OOB) => String,
|
#[xml(extract(fields(text)))]
|
||||||
|
pub url: String,
|
||||||
|
|
||||||
/// An optional description of the out of band data.
|
/// An optional description of the out of band data.
|
||||||
desc: Option<String> = ("desc", OOB) => String,
|
#[xml(extract(default, fields(text(type_ = String))))]
|
||||||
]
|
pub desc: Option<String>,
|
||||||
);
|
}
|
||||||
|
|
||||||
impl MessagePayload for Oob {}
|
impl MessagePayload for Oob {}
|
||||||
|
|
||||||
|
|
@ -63,6 +67,6 @@ mod tests {
|
||||||
FromElementError::Invalid(Error::Other(string)) => string,
|
FromElementError::Invalid(Error::Other(string)) => string,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
assert_eq!(message, "Missing child url in x element.");
|
assert_eq!(message, "Missing child field 'url' in Oob element.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue