hashes, presence, message, iq, disco: Use get_attr!.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-22 19:00:04 +01:00
commit d61d09f5b7
5 changed files with 32 additions and 59 deletions

View file

@ -76,10 +76,7 @@ impl<'a> TryFrom<&'a Element> for Hash {
for _ in elem.children() {
return Err(Error::ParseError("Unknown child in hash element."));
}
let algo = match elem.attr("algo") {
None => Err(Error::ParseError("Mandatory argument 'algo' not present in hash element.")),
Some(text) => Algo::from_str(text),
}?;
let algo = get_attr!(elem, "algo", required);
let hash = match elem.text().as_ref() {
"" => return Err(Error::ParseError("Hash element shouldnt be empty.")),
text => text.to_owned(),