parsers: port more generate_element! usages to derive macros
This commit is contained in:
parent
4e9c4883a3
commit
cea246a0fc
13 changed files with 200 additions and 151 deletions
|
|
@ -28,17 +28,18 @@ generate_element!(
|
|||
]
|
||||
);
|
||||
|
||||
generate_element!(
|
||||
/// An affiliation element.
|
||||
Affiliation, "affiliation", PUBSUB_OWNER,
|
||||
attributes: [
|
||||
/// The node this affiliation pertains to.
|
||||
jid: Required<Jid> = "jid",
|
||||
/// An affiliation element.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB_OWNER, name = "affiliation")]
|
||||
pub struct Affiliation {
|
||||
/// The node this affiliation pertains to.
|
||||
#[xml(attribute)]
|
||||
jid: Jid,
|
||||
|
||||
/// The affiliation you currently have on this node.
|
||||
affiliation: Required<AffiliationAttribute> = "affiliation",
|
||||
]
|
||||
);
|
||||
/// The affiliation you currently have on this node.
|
||||
#[xml(attribute)]
|
||||
affiliation: AffiliationAttribute,
|
||||
}
|
||||
|
||||
generate_element!(
|
||||
/// Request to configure a node.
|
||||
|
|
@ -84,14 +85,14 @@ pub struct Redirect {
|
|||
pub uri: String,
|
||||
}
|
||||
|
||||
generate_element!(
|
||||
/// Request to delete a node.
|
||||
Purge, "purge", PUBSUB_OWNER,
|
||||
attributes: [
|
||||
/// The node to be configured.
|
||||
node: Required<NodeName> = "node",
|
||||
]
|
||||
);
|
||||
/// Request to clear a node.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB_OWNER, name = "purge")]
|
||||
pub struct Purge {
|
||||
/// The node to be cleared.
|
||||
#[xml(attribute)]
|
||||
pub node: NodeName,
|
||||
}
|
||||
|
||||
generate_element!(
|
||||
/// A request for current subscriptions.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ use crate::pubsub::{
|
|||
};
|
||||
use crate::Element;
|
||||
use jid::Jid;
|
||||
use xso::error::{Error, FromElementError};
|
||||
use xso::{
|
||||
error::{Error, FromElementError},
|
||||
FromXml, IntoXml,
|
||||
};
|
||||
|
||||
// TODO: a better solution would be to split this into a query and a result elements, like for
|
||||
// XEP-0030.
|
||||
|
|
@ -29,17 +32,18 @@ generate_element!(
|
|||
]
|
||||
);
|
||||
|
||||
generate_element!(
|
||||
/// An affiliation element.
|
||||
Affiliation, "affiliation", PUBSUB,
|
||||
attributes: [
|
||||
/// The node this affiliation pertains to.
|
||||
node: Required<NodeName> = "node",
|
||||
/// An affiliation element.
|
||||
#[derive(FromXml, IntoXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = ns::PUBSUB, name = "affiliation")]
|
||||
pub struct Affiliation {
|
||||
/// The node this affiliation pertains to.
|
||||
#[xml(attribute)]
|
||||
pub node: NodeName,
|
||||
|
||||
/// The affiliation you currently have on this node.
|
||||
affiliation: Required<AffiliationAttribute> = "affiliation",
|
||||
]
|
||||
);
|
||||
/// The affiliation you currently have on this node.
|
||||
#[xml(attribute)]
|
||||
pub affiliation: AffiliationAttribute,
|
||||
}
|
||||
|
||||
generate_element!(
|
||||
/// Request to configure a new node.
|
||||
|
|
|
|||
Loading…
Reference in a new issue