mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
pubsub: provide accessor function for event's source node's name
Handy if you want to prefilter or distribute events based on the source node's name.
This commit is contained in:
parent
1449d300dd
commit
675907ba20
1 changed files with 14 additions and 0 deletions
|
@ -241,6 +241,20 @@ impl From<PubSubEvent> for Element {
|
|||
}
|
||||
}
|
||||
|
||||
impl PubSubEvent {
|
||||
/// Return the name of the node to which this event is related.
|
||||
pub fn node_name(&self) -> &NodeName {
|
||||
match self {
|
||||
Self::Purge { node, .. } => &node,
|
||||
Self::PublishedItems { node, .. } => &node,
|
||||
Self::RetractedItems { node, .. } => &node,
|
||||
Self::Subscription { node, .. } => &node,
|
||||
Self::Delete { node, .. } => &node,
|
||||
Self::Configuration { node, .. } => &node,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MessagePayload for PubSubEvent {}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue