roster: Make Group a proper struct.

This commit is contained in:
Emmanuel Gil Peyrot 2017-07-29 05:36:59 +01:00
commit 6ec1e46953
2 changed files with 33 additions and 7 deletions

View file

@ -144,6 +144,28 @@ macro_rules! generate_id {
);
}
macro_rules! generate_elem_id {
($elem:ident, $name:tt, $ns:expr) => (
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct $elem(pub String);
impl FromStr for $elem {
type Err = Error;
fn from_str(s: &str) -> Result<$elem, Error> {
// TODO: add a way to parse that differently when needed.
Ok($elem(String::from(s)))
}
}
impl From<$elem> for Element {
fn from(elem: $elem) -> Element {
Element::builder($name)
.ns($ns)
.append(elem.0)
.build()
}
}
);
}
/// Error type returned by every parser on failure.
pub mod error;
/// XML namespace definitions used through XMPP.