[][src]Struct libstrophe::Connection

pub struct Connection<'cb, 'cx> { /* fields omitted */ }

Proxy to the underlying xmpp_conn_t struct.

Most of the methods in this struct mimic the methods of the underlying library. So please see libstrophe docs for connection and handlers plus conn.c and handler.c sources. Only where it's not the case or there is some additional logic involved then you can see the method description.

This struct implements:

Methods

impl<'cb, 'cx> Connection<'cb, 'cx>[src]

pub fn new(ctx: Context<'cx, 'cb>) -> Self[src]

pub fn flags(&self) -> ConnectionFlags[src]

pub fn set_flags(&mut self, flags: ConnectionFlags) -> EmptyResult[src]

pub fn jid(&self) -> Option<&str>[src]

pub fn bound_jid(&self) -> Option<&str>[src]

pub fn set_jid(&mut self, jid: impl AsRef<str>)[src]

pub fn pass(&self) -> Option<&str>[src]

pub fn set_pass(&mut self, pass: impl AsRef<str>)[src]

pub fn disable_tls(&mut self)[src]

pub fn is_secured(&self) -> bool[src]

pub fn set_keepalive(&mut self, timeout: Duration, interval: Duration)[src]

pub fn connect_client<CB>(
    self,
    alt_host: Option<&str>,
    alt_port: impl Into<Option<u16>>,
    handler: CB
) -> Result<Context<'cx, 'cb>, ConnectError<'cb, 'cx>> where
    CB: FnMut(&Context<'cx, 'cb>, &mut Connection<'cb, 'cx>, ConnectionEvent, i32, Option<&StreamError>) + Send + 'cb, 
[src]

xmpp_connect_client

Pre-last error: i32 argument in the handler contains a TLS error code that can be passed together with XMPP_CONN_DISCONNECT event. The specific meaning if that code depends on the underlying TLS implementation:

Additionally the following OS dependent error constants can be set for error:

  • ETIMEDOUT/WSAETIMEDOUT
  • ECONNRESET/WSAECONNRESET
  • ECONNABORTED/WSAECONNABORTED

pub fn connect_component<CB>(
    self,
    host: impl AsRef<str>,
    port: impl Into<Option<u16>>,
    handler: CB
) -> Result<Context<'cx, 'cb>, ConnectError<'cb, 'cx>> where
    CB: FnMut(&Context<'cx, 'cb>, &mut Connection<'cb, 'cx>, ConnectionEvent, i32, Option<&StreamError>) + Send + 'cb, 
[src]

xmpp_connect_component

See also connect_client() for additional info.

pub fn connect_raw<CB>(
    self,
    alt_host: Option<&str>,
    alt_port: impl Into<Option<u16>>,
    handler: CB
) -> Result<Context<'cx, 'cb>, ConnectError<'cb, 'cx>> where
    CB: FnMut(&Context<'cx, 'cb>, &mut Connection<'cb, 'cx>, ConnectionEvent, i32, Option<&StreamError>) + Send + 'cb, 
[src]

xmpp_connect_raw

See also connect_client() for additional info.

pub fn open_stream_default(&self) -> EmptyResult[src]

pub fn open_stream(&self, attributes: &HashMap<&str, &str>) -> EmptyResult[src]

pub fn tls_start(&self) -> EmptyResult[src]

pub fn disconnect(&mut self)[src]

pub fn send_raw_string(&mut self, data: impl AsRef<str>)[src]

xmpp_send_raw_string

Be aware that this method performs a lot of allocations internally so you might want to use send_raw() instead.

pub fn send_raw(&mut self, data: impl AsRef<[u8]>)[src]

xmpp_send_raw

Be aware that this method doesn't print debug log line with the message being sent (unlike send_raw_string()).

pub fn send(&mut self, stanza: &Stanza)[src]

pub fn timed_handler_add<CB>(
    &mut self,
    handler: CB,
    period: Duration
) -> Option<TimedHandlerId<'cb, 'cx, CB>> where
    CB: FnMut(&Context<'cx, 'cb>, &mut Connection<'cb, 'cx>) -> bool + Send + 'cb, 
[src]

xmpp_timed_handler_add

See handler_add() for additional information.

pub fn timed_handler_delete<CB>(&mut self, handler_id: TimedHandlerId<CB>)[src]

xmpp_timed_handler_delete

See handler_delete() for additional information.

pub fn timed_handlers_clear(&mut self)[src]

See handlers_clear() for additional information.

pub fn id_handler_add<CB>(
    &mut self,
    handler: CB,
    id: impl Into<String>
) -> Option<IdHandlerId<'cb, 'cx, CB>> where
    CB: FnMut(&Context<'cx, 'cb>, &mut Connection<'cb, 'cx>, &Stanza) -> bool + Send + 'cb, 
[src]

xmpp_id_handler_add

See handler_add() for additional information.

pub fn id_handler_delete<CB>(&mut self, handler_id: IdHandlerId<CB>)[src]

xmpp_id_handler_delete

See handler_delete() for additional information.

pub fn id_handlers_clear(&mut self)[src]

See handlers_clear() for additional information.

pub fn handler_add<CB>(
    &mut self,
    handler: CB,
    ns: Option<&str>,
    name: Option<&str>,
    typ: Option<&str>
) -> Option<HandlerId<'cb, 'cx, CB>> where
    CB: FnMut(&Context<'cx, 'cb>, &mut Connection<'cb, 'cx>, &Stanza) -> bool + Send + 'cb, 
[src]

xmpp_handler_add

This function returns HandlerId which is later can be used to remove the handler using handler_delete().

pub fn handler_delete<CB>(&mut self, handler_id: HandlerId<CB>)[src]

xmpp_handler_delete

This version of this function accepts HandlerId returned from add_handler() function instead of function reference as the underlying library does. If you can't keep track of those handles, but still want ability to remove handlers, check handlers_clear() function.

pub fn handlers_clear(&mut self)[src]

Removes all handlers that were set up with handler_add(). This function does not remove handlers added via id_handler_add(). You can use this function if you can't keep track of specific closure handles returned from handler_add(), but want to remove handlers anyway.

Trait Implementations

impl<'_, '_> Drop for Connection<'_, '_>[src]

impl<'_, '_> PartialEq<Connection<'_, '_>> for Connection<'_, '_>[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<'_, '_> Eq for Connection<'_, '_>[src]

impl<'_, '_> Send for Connection<'_, '_>[src]

impl<'cb, 'cx> Debug for Connection<'cb, 'cx>[src]

Auto Trait Implementations

impl<'cb, 'cx> !Sync for Connection<'cb, 'cx>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]