xmpp_parsers/pubsub/mod.rs
1// Copyright (c) 2017 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7/// The `http://jabber.org/protocol/pubsub#event` protocol.
8pub mod event;
9
10/// The `http://jabber.org/protocol/pubsub#owner` protocol.
11pub mod owner;
12
13/// The `http://jabber.org/protocol/pubsub` protocol.
14#[allow(clippy::module_inception)]
15pub mod pubsub;
16
17pub use self::event::Event;
18pub use self::owner::Owner;
19pub use self::pubsub::PubSub;
20
21use minidom::Element;
22
23generate_id!(
24 /// The name of a PubSub node, used to identify it on a JID.
25 NodeName
26);
27
28generate_id!(
29 /// The identifier of an item, which is unique per node.
30 ItemId
31);
32
33generate_id!(
34 /// The identifier of a subscription to a PubSub node.
35 SubscriptionId
36);
37
38generate_attribute!(
39 /// The state of a subscription to a node.
40 Subscription, "subscription", {
41 /// The user is not subscribed to this node.
42 None => "none",
43
44 /// The user’s subscription to this node is still pending.
45 Pending => "pending",
46
47 /// The user is subscribed to this node.
48 Subscribed => "subscribed",
49
50 /// The user’s subscription to this node will only be valid once
51 /// configured.
52 Unconfigured => "unconfigured",
53 }, Default = None
54);
55
56generate_attribute!(
57 /// A list of possible affiliations to a node.
58 AffiliationAttribute, "affiliation", {
59 /// You are a member of this node, you can subscribe and retrieve items.
60 Member => "member",
61
62 /// You don’t have a specific affiliation with this node, you can only subscribe to it.
63 None => "none",
64
65 /// You are banned from this node.
66 Outcast => "outcast",
67
68 /// You are an owner of this node, and can do anything with it.
69 Owner => "owner",
70
71 /// You are a publisher on this node, you can publish and retract items to it.
72 Publisher => "publisher",
73
74 /// You can publish and retract items on this node, but not subscribe or retrieve items.
75 PublishOnly => "publish-only",
76 }
77);
78
79/// This trait should be implemented on any element which can be included as a PubSub payload.
80pub trait PubSubPayload: TryFrom<Element> + Into<Element> {}