Do some manual formatting in macros.
This commit is contained in:
parent
f6593aa74b
commit
96c8b05677
4 changed files with 47 additions and 44 deletions
|
@ -29,7 +29,7 @@ macro_rules! get_attr {
|
||||||
"Required attribute '",
|
"Required attribute '",
|
||||||
$attr,
|
$attr,
|
||||||
"' missing."
|
"' missing."
|
||||||
)))
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -169,9 +169,12 @@ macro_rules! generate_element_enum {
|
||||||
}
|
}
|
||||||
impl From<$elem> for ::minidom::Element {
|
impl From<$elem> for ::minidom::Element {
|
||||||
fn from(elem: $elem) -> ::minidom::Element {
|
fn from(elem: $elem) -> ::minidom::Element {
|
||||||
::minidom::Element::builder(match elem {
|
::minidom::Element::builder(
|
||||||
|
match elem {
|
||||||
$($elem::$enum => $enum_name,)+
|
$($elem::$enum => $enum_name,)+
|
||||||
}).ns(crate::ns::$ns)
|
}
|
||||||
|
)
|
||||||
|
.ns(crate::ns::$ns)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl TryFrom<Element> for Actor {
|
||||||
(Some(_), Some(_)) | (None, None) => {
|
(Some(_), Some(_)) | (None, None) => {
|
||||||
return Err(Error::ParseError(
|
return Err(Error::ParseError(
|
||||||
"Either 'jid' or 'nick' attribute is required.",
|
"Either 'jid' or 'nick' attribute is required.",
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
(Some(jid), _) => Ok(Actor::Jid(jid)),
|
(Some(jid), _) => Ok(Actor::Jid(jid)),
|
||||||
(_, Some(nick)) => Ok(Actor::Nick(nick)),
|
(_, Some(nick)) => Ok(Actor::Nick(nick)),
|
||||||
|
|
|
@ -136,7 +136,7 @@ impl FromStr for Type {
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Error::ParseError(
|
return Err(Error::ParseError(
|
||||||
"Invalid 'type' attribute on presence element.",
|
"Invalid 'type' attribute on presence element.",
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ fn parse_items(elem: Element, node: NodeName) -> Result<PubSubEvent, Error> {
|
||||||
Some(true) => {
|
Some(true) => {
|
||||||
return Err(Error::ParseError(
|
return Err(Error::ParseError(
|
||||||
"Mix of item and retract in items element.",
|
"Mix of item and retract in items element.",
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
items.push(Item::try_from(child.clone())?);
|
items.push(Item::try_from(child.clone())?);
|
||||||
|
@ -149,7 +149,7 @@ fn parse_items(elem: Element, node: NodeName) -> Result<PubSubEvent, Error> {
|
||||||
Some(false) => {
|
Some(false) => {
|
||||||
return Err(Error::ParseError(
|
return Err(Error::ParseError(
|
||||||
"Mix of item and retract in items element.",
|
"Mix of item and retract in items element.",
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check_no_children!(child, "retract");
|
check_no_children!(child, "retract");
|
||||||
|
|
Loading…
Reference in a new issue