mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
edit some documentation on Client and ClientBuilder
This commit is contained in:
parent
e6eb65e6c6
commit
fe5b6ed490
1 changed files with 9 additions and 9 deletions
|
@ -22,7 +22,7 @@ pub struct ClientBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientBuilder {
|
impl ClientBuilder {
|
||||||
/// Create a new builder for an XMPP client that will connect to `jid` with default parameters.
|
/// Creates a new builder for an XMPP client that will connect to `jid` with default parameters.
|
||||||
pub fn new(jid: Jid) -> ClientBuilder {
|
pub fn new(jid: Jid) -> ClientBuilder {
|
||||||
ClientBuilder {
|
ClientBuilder {
|
||||||
jid: jid,
|
jid: jid,
|
||||||
|
@ -31,13 +31,13 @@ impl ClientBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the host to connect to.
|
/// Sets the host to connect to.
|
||||||
pub fn host(mut self, host: String) -> ClientBuilder {
|
pub fn host(mut self, host: String) -> ClientBuilder {
|
||||||
self.host = Some(host);
|
self.host = Some(host);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the port to connect to.
|
/// Sets the port to connect to.
|
||||||
pub fn port(mut self, port: u16) -> ClientBuilder {
|
pub fn port(mut self, port: u16) -> ClientBuilder {
|
||||||
self.port = port;
|
self.port = port;
|
||||||
self
|
self
|
||||||
|
@ -72,18 +72,18 @@ pub struct Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
/// Return a reference to the `Jid` associated with this `Client`.
|
/// Returns a reference to the `Jid` associated with this `Client`.
|
||||||
pub fn jid(&self) -> &Jid {
|
pub fn jid(&self) -> &Jid {
|
||||||
&self.jid
|
&self.jid
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register a plugin.
|
/// Registers a plugin.
|
||||||
pub fn register_plugin<P: Plugin + 'static>(&mut self, mut plugin: P) {
|
pub fn register_plugin<P: Plugin + 'static>(&mut self, mut plugin: P) {
|
||||||
plugin.bind(self.binding.clone());
|
plugin.bind(self.binding.clone());
|
||||||
self.plugins.push(Box::new(plugin));
|
self.plugins.push(Box::new(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the plugin given by the type parameter, if it exists, else panic.
|
/// Returns the plugin given by the type parameter, if it exists, else panics.
|
||||||
pub fn plugin<P: Plugin>(&self) -> &P {
|
pub fn plugin<P: Plugin>(&self) -> &P {
|
||||||
for plugin in &self.plugins {
|
for plugin in &self.plugins {
|
||||||
let any = plugin.as_any();
|
let any = plugin.as_any();
|
||||||
|
@ -94,7 +94,7 @@ impl Client {
|
||||||
panic!("plugin does not exist!");
|
panic!("plugin does not exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the next event and flush the send queue.
|
/// Returns the next event and flush the send queue.
|
||||||
pub fn next_event(&mut self) -> Result<AbstractEvent, Error> {
|
pub fn next_event(&mut self) -> Result<AbstractEvent, Error> {
|
||||||
self.flush_send_queue()?;
|
self.flush_send_queue()?;
|
||||||
loop {
|
loop {
|
||||||
|
@ -110,7 +110,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flush the send queue, sending all queued up stanzas.
|
/// Flushes the send queue, sending all queued up stanzas.
|
||||||
pub fn flush_send_queue(&mut self) -> Result<(), Error> { // TODO: not sure how great of an
|
pub fn flush_send_queue(&mut self) -> Result<(), Error> { // TODO: not sure how great of an
|
||||||
// idea it is to flush in this
|
// idea it is to flush in this
|
||||||
// manner…
|
// manner…
|
||||||
|
@ -120,7 +120,7 @@ impl Client {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connect using SASL plain authentication.
|
/// Connects using SASL plain authentication.
|
||||||
pub fn connect_plain(&mut self, password: &str) -> Result<(), Error> {
|
pub fn connect_plain(&mut self, password: &str) -> Result<(), Error> {
|
||||||
// TODO: this is very ugly
|
// TODO: this is very ugly
|
||||||
loop {
|
loop {
|
||||||
|
|
Loading…
Reference in a new issue