From a2c752966881d46a904222ab35d3a551fc7492d9 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 10 Oct 2017 18:10:52 +0100 Subject: [PATCH] eme: Use the new helper macros to simplify parsing. --- src/eme.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/eme.rs b/src/eme.rs index 288431b..ad4b437 100644 --- a/src/eme.rs +++ b/src/eme.rs @@ -27,12 +27,9 @@ impl TryFrom for ExplicitMessageEncryption { type Err = Error; fn try_from(elem: Element) -> Result { - if !elem.is("encryption", ns::EME) { - return Err(Error::ParseError("This is not an encryption element.")); - } - for _ in elem.children() { - return Err(Error::ParseError("Unknown child in encryption element.")); - } + check_self!(elem, "encryption", ns::EME); + check_no_children!(elem, "encryption"); + check_no_unknown_attributes!(elem, "encryption", ["namespace", "name"]); Ok(ExplicitMessageEncryption { namespace: get_attr!(elem, "namespace", required), name: get_attr!(elem, "name", optional), @@ -75,7 +72,7 @@ mod tests { Error::ParseError(string) => string, _ => panic!(), }; - assert_eq!(message, "This is not an encryption element."); + assert_eq!(message, "This is not a encryption element."); } #[test]