Struct libstrophe::Stanza

source ·
pub struct Stanza { /* private fields */ }
Expand description

Proxy to the underlying xmpp_stanza_t struct.

Most of the methods in this struct mimic the methods of the underlying library. So please see libstrophe docs and 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:

Implementations§

source§

impl Stanza

source

pub fn new() -> Self

xmpp_stanza_new

The newly created stanza is not really useful until you assign an internal type to it. To do that you must call set_text() to make it XMPP_STANZA_TEXT stanza or set_name() to make it XMPP_STANZA_TAG stanza.

source

pub fn new_presence() -> Self

source

pub fn new_iq(typ: Option<&str>, id: Option<&str>) -> Self

source

pub fn new_message( typ: Option<&str>, id: Option<&str>, to: Option<&str> ) -> Self

source

pub fn new_error(typ: ErrorType, text: Option<&str>) -> Self

source

pub fn from_str(s: impl AsRef<str>) -> Self

source

pub unsafe fn from_owned(inner: *mut xmpp_stanza_t) -> Self

Create an owning stanza from the raw pointer

Safety

inner must be a valid pointer to a previously allocated xmpp_stanza_t and you must make sure that there are no other usages of that pointer after calling this function.

source

pub unsafe fn from_ref<'st>(inner: *const xmpp_stanza_t) -> StanzaRef<'st>

Create a borrowing stanza from the constant raw pointer

Safety

inner must be a valid pointer to a previously allocated xmpp_stanza_t and you must make sure that Self doesn’t outlive the stanza behind that pointer

source

pub unsafe fn from_ref_mut<'st>(inner: *mut xmpp_stanza_t) -> StanzaMutRef<'st>

Create a borrowing stanza from the mutable raw pointer

Safety

inner must be a valid pointer to a previously allocated mutable xmpp_stanza_t and you must make sure that Self doesn’t outlive the stanza behind that pointer

source

pub fn is_text(&self) -> bool

source

pub fn is_tag(&self) -> bool

source

pub fn to_text(&self) -> Result<String, ToTextError>

source

pub fn set_name(&mut self, name: impl AsRef<str>) -> Result<()>

xmpp_stanza_set_name

Be aware that calling this method changes the internal type of stanza to XMPP_STANZA_TAG.

source

pub fn name(&self) -> Option<&str>

source

pub fn attribute_count(&self) -> i32

source

pub fn set_attribute( &mut self, name: impl AsRef<str>, value: impl AsRef<str> ) -> Result<()>

source

pub fn get_attribute(&self, name: impl AsRef<str>) -> Option<&str>

source

pub fn attributes(&self) -> HashMap<&str, &str>

xmpp_stanza_get_attributes

This method returns data as HashMap unlike underlying function.

source

pub fn del_attribute(&mut self, name: impl AsRef<str>) -> Result<()>

source

pub fn set_text(&mut self, text: impl AsRef<str>) -> Result<()>

xmpp_stanza_set_text_with_size

Be aware that calling this method changes the internal type of stanza to XMPP_STANZA_TEXT.

source

pub fn text(&self) -> Option<String>

source

pub fn set_id(&mut self, id: impl AsRef<str>) -> Result<()>

source

pub fn id(&self) -> Option<&str>

source

pub fn set_ns(&mut self, ns: impl AsRef<str>) -> Result<()>

source

pub fn ns(&self) -> Option<&str>

source

pub fn set_stanza_type(&mut self, typ: impl AsRef<str>) -> Result<()>

source

pub fn stanza_type(&self) -> Option<&str>

source

pub fn set_to(&mut self, to: impl AsRef<str>) -> Result<()>

source

pub fn to(&self) -> Option<&str>

source

pub fn set_from(&mut self, from: impl AsRef<str>) -> Result<()>

source

pub fn from(&self) -> Option<&str>

source

pub fn get_first_child(&self) -> Option<StanzaRef<'_>>

source

pub fn get_first_child_mut(&mut self) -> Option<StanzaMutRef<'_>>

source

pub fn get_child_by_ns(&self, ns: impl AsRef<str>) -> Option<StanzaRef<'_>>

source

pub fn get_child_by_ns_mut( &mut self, ns: impl AsRef<str> ) -> Option<StanzaMutRef<'_>>

source

pub fn get_child_by_name(&self, name: impl AsRef<str>) -> Option<StanzaRef<'_>>

source

pub fn get_child_by_name_mut( &mut self, name: impl AsRef<str> ) -> Option<StanzaMutRef<'_>>

source

pub fn get_child_by_name_and_ns( &self, name: impl AsRef<str>, ns: impl AsRef<str> ) -> Option<StanzaRef<'_>>

source

pub fn get_child_by_name_and_ns_mut( &mut self, name: impl AsRef<str>, ns: impl AsRef<str> ) -> Option<StanzaMutRef<'_>>

source

pub fn get_child_by_path(&self, path: &[&str]) -> Option<StanzaRef<'_>>

xmpp_stanza_get_child_by_path

Due to internal limitations (vararg call in C) this function supports a maximum of 10 elements in the path slice.

source

pub fn get_child_by_path_mut( &mut self, path: &[&str] ) -> Option<StanzaMutRef<'_>>

xmpp_stanza_get_child_by_path

Due to internal limitations (vararg call in C) this function supports a maximum of 10 elements in the path slice.

source

pub fn children(&self) -> impl Iterator<Item = StanzaRef<'_>>

source

pub fn children_mut(&mut self) -> impl Iterator<Item = StanzaMutRef<'_>>

source

pub fn get_next(&self) -> Option<StanzaRef<'_>>

source

pub fn get_next_mut(&mut self) -> Option<StanzaMutRef<'_>>

source

pub fn add_child(&mut self, child: Stanza) -> Result<()>

source

pub fn reply(&self) -> Self

source

pub fn reply_error( &self, error_type: impl AsRef<str>, condition: impl AsRef<str>, text: impl AsRef<str> ) -> Self

source

pub fn set_body(&mut self, body: impl AsRef<str>) -> Result<()>

source

pub fn body(&self) -> Option<String>

Trait Implementations§

source§

impl Clone for Stanza

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Stanza

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Stanza

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Stanza

source§

impl Drop for Stanza

source§

impl<'st> From<Stanza> for StanzaMutRef<'st>

source§

fn from(s: Stanza) -> Self

Converts to this type from the input type.
source§

impl<'st> From<Stanza> for StanzaRef<'st>

source§

fn from(s: Stanza) -> Self

Converts to this type from the input type.
source§

impl FromStr for Stanza

§

type Err = ()

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Stanza

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Stanza> for Stanza

source§

fn eq(&self, other: &Stanza) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Stanza

source§

impl Send for Stanza

source§

impl StructuralEq for Stanza

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.