pubsub: Document all of the modules.

This commit is contained in:
Emmanuel Gil Peyrot 2018-08-02 22:16:55 +02:00
parent 89efc89423
commit 92cdaaafcc
3 changed files with 74 additions and 12 deletions

View file

@ -18,11 +18,17 @@ use data_forms::DataForm;
use pubsub::{NodeName, ItemId, Subscription, SubscriptionId}; use pubsub::{NodeName, ItemId, Subscription, SubscriptionId};
/// One PubSub item from a node.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Item { pub struct Item {
pub payload: Option<Element>, /// The identifier for this item, unique per node.
pub id: Option<ItemId>, pub id: Option<ItemId>,
/// The JID of the entity who published this item.
pub publisher: Option<Jid>, pub publisher: Option<Jid>,
/// The actual content of this item.
pub payload: Option<Element>,
} }
impl TryFrom<Element> for Item { impl TryFrom<Element> for Item {
@ -55,36 +61,70 @@ impl From<Item> for Element {
} }
} }
/// Represents an event happening to a PubSub node.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum PubSubEvent { pub enum PubSubEvent {
/* /*
Collection { Collection {
}, },
*/ */
/// This nodes configuration changed.
Configuration { Configuration {
/// The node affected.
node: NodeName, node: NodeName,
/// The new configuration of this node.
form: Option<DataForm>, form: Option<DataForm>,
}, },
/// This node has been deleted, with an optional redirect to another node.
Delete { Delete {
/// The node affected.
node: NodeName, node: NodeName,
/// The xmpp: URI of another node replacing this one.
redirect: Option<String>, redirect: Option<String>,
}, },
/// Some items have been published on this node.
PublishedItems { PublishedItems {
/// The node affected.
node: NodeName, node: NodeName,
/// The list of published items.
items: Vec<Item>, items: Vec<Item>,
}, },
/// Some items have been removed from this node.
RetractedItems { RetractedItems {
/// The node affected.
node: NodeName, node: NodeName,
/// The list of retracted items.
items: Vec<ItemId>, items: Vec<ItemId>,
}, },
/// All items of this node just got removed at once.
Purge { Purge {
/// The node affected.
node: NodeName, node: NodeName,
}, },
/// The users subscription to this node has changed.
Subscription { Subscription {
/// The node affected.
node: NodeName, node: NodeName,
/// The time at which this subscription will expire.
expiry: Option<DateTime>, expiry: Option<DateTime>,
/// The JID of the user affected.
jid: Option<Jid>, jid: Option<Jid>,
/// An identifier for this subscription.
subid: Option<SubscriptionId>, subid: Option<SubscriptionId>,
/// The state of this subscription.
subscription: Option<Subscription>, subscription: Option<Subscription>,
}, },
} }

View file

@ -4,6 +4,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
//#![deny(missing_docs)]
/// The `http://jabber.org/protocol/pubsub#event` protocol. /// The `http://jabber.org/protocol/pubsub#event` protocol.
pub mod event; pub mod event;
@ -13,13 +15,35 @@ pub mod pubsub;
pub use self::event::PubSubEvent; pub use self::event::PubSubEvent;
pub use self::pubsub::PubSub; pub use self::pubsub::PubSub;
generate_id!(NodeName); generate_id!(
generate_id!(ItemId); /// The name of a PubSub node, used to identify it on a JID.
generate_id!(SubscriptionId); NodeName
);
generate_attribute!(Subscription, "subscription", { generate_id!(
/// The identifier of an item, which is unique per node.
ItemId
);
generate_id!(
/// The identifier of a subscription to a PubSub node.
SubscriptionId
);
generate_attribute!(
/// The state of a subscription to a node.
Subscription, "subscription", {
/// The user is not subscribed to this node.
None => "none", None => "none",
/// The users subscription to this node is still pending.
Pending => "pending", Pending => "pending",
/// The user is subscribed to this node.
Subscribed => "subscribed", Subscribed => "subscribed",
/// The users subscription to this node will only be valid once
/// configured.
Unconfigured => "unconfigured", Unconfigured => "unconfigured",
}, Default = None); }, Default = None
);

View file

@ -4,8 +4,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#![deny(missing_docs)]
use try_from::TryFrom; use try_from::TryFrom;
use minidom::Element; use minidom::Element;