From e6eb65e6c6395ffefc0c0bde61b3735d91dfdb51 Mon Sep 17 00:00:00 2001 From: lumi Date: Tue, 21 Feb 2017 13:58:24 +0100 Subject: [PATCH] document Client --- src/client.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client.rs b/src/client.rs index 9e3c54b..48b34b7 100644 --- a/src/client.rs +++ b/src/client.rs @@ -61,6 +61,7 @@ impl ClientBuilder { } } +/// An XMPP client. pub struct Client { jid: Jid, transport: SslTransport, @@ -71,15 +72,18 @@ pub struct Client { } impl Client { + /// Return a reference to the `Jid` associated with this `Client`. pub fn jid(&self) -> &Jid { &self.jid } + /// Register a plugin. pub fn register_plugin(&mut self, mut plugin: P) { plugin.bind(self.binding.clone()); self.plugins.push(Box::new(plugin)); } + /// Return the plugin given by the type parameter, if it exists, else panic. pub fn plugin(&self) -> &P { for plugin in &self.plugins { let any = plugin.as_any(); @@ -90,6 +94,7 @@ impl Client { panic!("plugin does not exist!"); } + /// Return the next event and flush the send queue. pub fn next_event(&mut self) -> Result { self.flush_send_queue()?; loop { @@ -105,6 +110,7 @@ impl Client { } } + /// Flush the send queue, sending all queued up stanzas. pub fn flush_send_queue(&mut self) -> Result<(), Error> { // TODO: not sure how great of an // idea it is to flush in this // manner… @@ -114,6 +120,7 @@ impl Client { Ok(()) } + /// Connect using SASL plain authentication. pub fn connect_plain(&mut self, password: &str) -> Result<(), Error> { // TODO: this is very ugly loop {