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:
Display
(xmpp_stanza_to_text)Eq
by comparing internal pointersHash
by hashing internal pointerDrop
(xmpp_stanza_release)Clone
(xmpp_stanza_copy)Send
Implementations§
source§impl Stanza
impl Stanza
sourcepub fn new() -> Self
pub fn new() -> Self
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.
sourcepub fn new_presence() -> Self
pub fn new_presence() -> Self
sourcepub unsafe fn from_owned(inner: *mut xmpp_stanza_t) -> Self
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.
sourcepub unsafe fn from_ref<'st>(inner: *const xmpp_stanza_t) -> StanzaRef<'st>
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
sourcepub unsafe fn from_ref_mut<'st>(inner: *mut xmpp_stanza_t) -> StanzaMutRef<'st>
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
sourcepub fn to_text(&self) -> Result<String, ToTextError>
pub fn to_text(&self) -> Result<String, ToTextError>
sourcepub fn set_name(&mut self, name: impl AsRef<str>) -> Result<()>
pub fn set_name(&mut self, name: impl AsRef<str>) -> Result<()>
Be aware that calling this method changes the internal type of stanza to XMPP_STANZA_TAG
.
sourcepub fn attribute_count(&self) -> i32
pub fn attribute_count(&self) -> i32
sourcepub fn set_attribute(
&mut self,
name: impl AsRef<str>,
value: impl AsRef<str>
) -> Result<()>
pub fn set_attribute( &mut self, name: impl AsRef<str>, value: impl AsRef<str> ) -> Result<()>
sourcepub fn attributes(&self) -> HashMap<&str, &str>
pub fn attributes(&self) -> HashMap<&str, &str>
This method returns data as HashMap
unlike underlying function.
sourcepub fn set_text(&mut self, text: impl AsRef<str>) -> Result<()>
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
.
sourcepub fn stanza_type(&self) -> Option<&str>
pub fn stanza_type(&self) -> Option<&str>
sourcepub fn get_first_child(&self) -> Option<StanzaRef<'_>>
pub fn get_first_child(&self) -> Option<StanzaRef<'_>>
sourcepub fn get_first_child_mut(&mut self) -> Option<StanzaMutRef<'_>>
pub fn get_first_child_mut(&mut self) -> Option<StanzaMutRef<'_>>
sourcepub fn get_child_by_ns_mut(
&mut self,
ns: impl AsRef<str>
) -> Option<StanzaMutRef<'_>>
pub fn get_child_by_ns_mut( &mut self, ns: impl AsRef<str> ) -> Option<StanzaMutRef<'_>>
sourcepub fn get_child_by_name_mut(
&mut self,
name: impl AsRef<str>
) -> Option<StanzaMutRef<'_>>
pub fn get_child_by_name_mut( &mut self, name: impl AsRef<str> ) -> Option<StanzaMutRef<'_>>
sourcepub fn get_child_by_name_and_ns(
&self,
name: impl AsRef<str>,
ns: impl AsRef<str>
) -> Option<StanzaRef<'_>>
pub fn get_child_by_name_and_ns( &self, name: impl AsRef<str>, ns: impl AsRef<str> ) -> Option<StanzaRef<'_>>
sourcepub fn get_child_by_name_and_ns_mut(
&mut self,
name: impl AsRef<str>,
ns: impl AsRef<str>
) -> Option<StanzaMutRef<'_>>
pub fn get_child_by_name_and_ns_mut( &mut self, name: impl AsRef<str>, ns: impl AsRef<str> ) -> Option<StanzaMutRef<'_>>
sourcepub fn get_child_by_path(&self, path: &[&str]) -> Option<StanzaRef<'_>>
pub fn get_child_by_path(&self, path: &[&str]) -> Option<StanzaRef<'_>>
Due to internal limitations (vararg call in C) this function supports a maximum of 10 elements
in the path
slice.
sourcepub fn get_child_by_path_mut(
&mut self,
path: &[&str]
) -> Option<StanzaMutRef<'_>>
pub fn get_child_by_path_mut( &mut self, path: &[&str] ) -> Option<StanzaMutRef<'_>>
Due to internal limitations (vararg call in C) this function supports a maximum of 10 elements
in the path
slice.