[−][src]Struct libstrophe::Connection
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:
Drop
(xmpp_conn_release).Eq
by comparing internal pointersSend
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]
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,
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:
- for
openssl
it's the result ofSSL_get_error()
- for
schannel
it's the result ofWSAGetLastError()
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]
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,
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]
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,
See also connect_client()
for additional info.
pub fn open_stream_default(&self) -> EmptyResult
[src]
Related to connect_raw()
.
pub fn open_stream(&self, attributes: &HashMap<&str, &str>) -> EmptyResult
[src]
Related to connect_raw()
.
pub fn tls_start(&self) -> EmptyResult
[src]
Related to connect_raw()
.
pub fn disconnect(&mut self)
[src]
pub fn send_raw_string(&mut self, data: impl AsRef<str>)
[src]
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]
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]
&mut self,
handler: CB,
period: Duration
) -> Option<TimedHandlerId<'cb, 'cx, CB>> where
CB: FnMut(&Context<'cx, 'cb>, &mut Connection<'cb, 'cx>) -> bool + Send + 'cb,
See handler_add()
for additional information.
pub fn timed_handler_delete<CB>(&mut self, handler_id: TimedHandlerId<CB>)
[src]
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]
&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,
See handler_add()
for additional information.
pub fn id_handler_delete<CB>(&mut self, handler_id: IdHandlerId<CB>)
[src]
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]
&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,
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]
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]
fn eq(&self, other: &Connection) -> bool
[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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,