Enum Iq

Source
pub enum Iq {
    Get {
        from: Option<Jid>,
        to: Option<Jid>,
        id: String,
        payload: Element,
    },
    Set {
        from: Option<Jid>,
        to: Option<Jid>,
        id: String,
        payload: Element,
    },
    Result {
        from: Option<Jid>,
        to: Option<Jid>,
        id: String,
        payload: Option<Element>,
    },
    Error {
        from: Option<Jid>,
        to: Option<Jid>,
        id: String,
        error: StanzaError,
        payload: Option<Element>,
    },
}
Expand description

The main structure representing the <iq/> stanza.

Variants§

§

Get

An <iq type='get'/> stanza.

Fields

§from: Option<Jid>

The JID emitting this stanza.

§to: Option<Jid>

The recipient of this stanza.

§id: String

The @id attribute of this stanza, which is required in order to match a request with its result/error.

§payload: Element

The payload content of this stanza.

§

Set

An <iq type='set'/> stanza.

Fields

§from: Option<Jid>

The JID emitting this stanza.

§to: Option<Jid>

The recipient of this stanza.

§id: String

The @id attribute of this stanza, which is required in order to match a request with its result/error.

§payload: Element

The payload content of this stanza.

§

Result

An <iq type='result'/> stanza.

Fields

§from: Option<Jid>

The JID emitting this stanza.

§to: Option<Jid>

The recipient of this stanza.

§id: String

The @id attribute of this stanza, which is required in order to match a request with its result/error.

§payload: Option<Element>

The payload content of this stanza.

§

Error

An <iq type='error'/> stanza.

Fields

§from: Option<Jid>

The JID emitting this stanza.

§to: Option<Jid>

The recipient of this stanza.

§id: String

The @id attribute of this stanza, which is required in order to match a request with its result/error.

§error: StanzaError

The error carried by this stanza.

§payload: Option<Element>

The optional payload content which caused the error.

As per RFC 6120 § 8.3.1, the emitter of an error stanza MAY include the original XML which caused the error. However, recipients MUST NOT rely on this.

Implementations§

Source§

impl Iq

Source

pub fn assemble(header: IqHeader, data: IqPayload) -> Self

Assemble a new Iq stanza from an IqHeader and the given IqPayload.

Source

pub fn from_get<S: Into<String>>(id: S, payload: impl IqGetPayload) -> Iq

Creates an <iq/> stanza containing a get request.

Source

pub fn from_set<S: Into<String>>(id: S, payload: impl IqSetPayload) -> Iq

Creates an <iq/> stanza containing a set request.

Source

pub fn empty_result<S: Into<String>>(to: Jid, id: S) -> Iq

Creates an empty <iq type="result"/> stanza.

Source

pub fn from_result<S: Into<String>>( id: S, payload: Option<impl IqResultPayload>, ) -> Iq

Creates an <iq/> stanza containing a result.

Source

pub fn from_error<S: Into<String>>(id: S, payload: StanzaError) -> Iq

Creates an <iq/> stanza containing an error.

Source

pub fn with_to(self, to: Jid) -> Iq

Sets the recipient of this stanza.

Source

pub fn with_from(self, from: Jid) -> Iq

Sets the emitter of this stanza.

Source

pub fn with_id(self, id: String) -> Iq

Sets the id of this stanza, in order to later match its response.

Source

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

Access the sender address.

Source

pub fn from_mut(&mut self) -> &mut Option<Jid>

Access the sender address, mutably.

Source

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

Access the recipient address.

Source

pub fn to_mut(&mut self) -> &mut Option<Jid>

Access the recipient address, mutably.

Source

pub fn id(&self) -> &str

Access the id.

Source

pub fn id_mut(&mut self) -> &mut String

Access the id mutably.

Source

pub fn split(self) -> (IqHeader, IqPayload)

Split the IQ stanza in its metadata and data.

Note that this discards the optional original error-inducing payload of the Iq::Error variant.

Source

pub fn into_header(self) -> IqHeader

Return the IqHeader of this stanza, discarding the payload.

Source

pub fn into_payload(self) -> IqPayload

Return the IqPayload of this stanza, discarding the header.

Note that this also discards the optional original error-inducing payload of the Iq::Error variant.

Trait Implementations§

Source§

impl AsXml for Iq

Source§

type ItemIter<'xso_proc_as_xml_iter_lifetime> = IqAsXmlIterator<'xso_proc_as_xml_iter_lifetime>

The iterator type. Read more
Source§

fn as_xml_iter(&self) -> Result<Self::ItemIter<'_>, Error>

Return an iterator which emits the contents of the struct or enum as serialisable Item items.
Source§

fn as_xml_dyn_iter<'x>( &'x self, ) -> Result<Box<dyn Iterator<Item = Result<Item<'x>, Error>> + 'x>, Error>

Return the same iterator as as_xml_iter, but boxed to erase the concrete iterator type. Read more
Source§

impl Clone for Iq

Source§

fn clone(&self) -> Iq

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 Iq

Source§

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

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

impl From<&Iq> for Element

Source§

fn from(other: &Iq) -> Self

Converts to this type from the input type.
Source§

impl From<Iq> for Element

Source§

fn from(other: Iq) -> Self

Converts to this type from the input type.
Source§

impl FromXml for Iq

Source§

type Builder = IqFromXmlBuilder

A builder type used to construct the element. Read more
Source§

fn from_events( name: QName, attrs: AttrMap, ctx: &Context<'_>, ) -> Result<Self::Builder, FromEventsError>

Attempt to initiate the streamed construction of this struct from XML. Read more
Source§

fn xml_name_matcher() -> XmlNameMatcher<'static>

Return a predicate which determines if Self may be parsed from a given XML element. Read more
Source§

impl PartialEq for Iq

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Element> for Iq

Source§

type Error = FromElementError

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

fn try_from(other: Element) -> Result<Self, FromElementError>

Performs the conversion.
Source§

impl StructuralPartialEq for Iq

Auto Trait Implementations§

§

impl Freeze for Iq

§

impl RefUnwindSafe for Iq

§

impl Send for Iq

§

impl Sync for Iq

§

impl Unpin for Iq

§

impl UnwindSafe for Iq

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsXmlDyn for T
where T: AsXml,

Source§

fn as_xml_dyn_iter<'x>( &'x self, ) -> Result<Box<dyn Iterator<Item = Result<Item<'x>, Error>> + 'x>, Error>

Return an iterator which emits the contents of the struct or enum as serialisable Item items by calling AsXml::as_xml_dyn_iter.

Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,