mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
message_correct: Use the new helper macros to simplify parsing.
This commit is contained in:
parent
cfbfce512e
commit
66fb8fea74
1 changed files with 3 additions and 11 deletions
|
@ -21,17 +21,9 @@ impl TryFrom<Element> for Replace {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
||||||
fn try_from(elem: Element) -> Result<Replace, Error> {
|
fn try_from(elem: Element) -> Result<Replace, Error> {
|
||||||
if !elem.is("replace", ns::MESSAGE_CORRECT) {
|
check_self!(elem, "replace", ns::MESSAGE_CORRECT);
|
||||||
return Err(Error::ParseError("This is not a replace element."));
|
check_no_children!(elem, "replace");
|
||||||
}
|
check_no_unknown_attributes!(elem, "replace", ["id"]);
|
||||||
for _ in elem.children() {
|
|
||||||
return Err(Error::ParseError("Unknown child in replace element."));
|
|
||||||
}
|
|
||||||
for (attr, _) in elem.attrs() {
|
|
||||||
if attr != "id" {
|
|
||||||
return Err(Error::ParseError("Unknown attribute in replace element."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let id = get_attr!(elem, "id", required);
|
let id = get_attr!(elem, "id", required);
|
||||||
Ok(Replace { id })
|
Ok(Replace { id })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue