jingle_ft: Obtain attributes using the get_attr! macro.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-21 21:02:06 +01:00
parent ca9a250efd
commit e7e4284a0d

View file

@ -138,11 +138,8 @@ impl<'a> TryFrom<&'a Element> for Description {
if range.is_some() { if range.is_some() {
return Err(Error::ParseError("File must not have more than one range.")); return Err(Error::ParseError("File must not have more than one range."));
} }
let offset = file_payload.attr("offset").unwrap_or("0").parse()?; let offset = get_attr!(file_payload, "offset", default);
let length = match file_payload.attr("length") { let length = get_attr!(file_payload, "length", optional);
Some(length) => Some(length.parse()?),
None => None,
};
let mut range_hashes = vec!(); let mut range_hashes = vec!();
for hash_element in file_payload.children() { for hash_element in file_payload.children() {
if !hash_element.is("hash", ns::HASHES) { if !hash_element.is("hash", ns::HASHES) {