blocking: Merge get_children_items into the try_from.
This commit is contained in:
parent
649286d59e
commit
47c9263b86
1 changed files with 8 additions and 14 deletions
|
@ -15,17 +15,6 @@ use ns;
|
||||||
|
|
||||||
generate_empty_element!(BlocklistRequest, "blocklist", ns::BLOCKING);
|
generate_empty_element!(BlocklistRequest, "blocklist", ns::BLOCKING);
|
||||||
|
|
||||||
fn get_children_items(elem: Element) -> Result<Vec<Jid>, Error> {
|
|
||||||
let mut items = vec!();
|
|
||||||
for child in elem.children() {
|
|
||||||
check_self!(child, "item", ns::BLOCKING);
|
|
||||||
check_no_unknown_attributes!(child, "item", ["jid"]);
|
|
||||||
check_no_children!(child, "item");
|
|
||||||
items.push(get_attr!(child, "jid", required));
|
|
||||||
}
|
|
||||||
Ok(items)
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! generate_blocking_element {
|
macro_rules! generate_blocking_element {
|
||||||
($elem:ident, $name:tt) => (
|
($elem:ident, $name:tt) => (
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -39,9 +28,14 @@ macro_rules! generate_blocking_element {
|
||||||
fn try_from(elem: Element) -> Result<$elem, Error> {
|
fn try_from(elem: Element) -> Result<$elem, Error> {
|
||||||
check_self!(elem, $name, ns::BLOCKING);
|
check_self!(elem, $name, ns::BLOCKING);
|
||||||
check_no_attributes!(elem, $name);
|
check_no_attributes!(elem, $name);
|
||||||
Ok($elem {
|
let mut items = vec!();
|
||||||
items: get_children_items(elem)?,
|
for child in elem.children() {
|
||||||
})
|
check_self!(child, "item", ns::BLOCKING);
|
||||||
|
check_no_unknown_attributes!(child, "item", ["jid"]);
|
||||||
|
check_no_children!(child, "item");
|
||||||
|
items.push(get_attr!(child, "jid", required));
|
||||||
|
}
|
||||||
|
Ok($elem { items })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue