[][src]Struct xmpp_parsers::message::Message

pub struct Message {
    pub from: Option<Jid>,
    pub to: Option<Jid>,
    pub id: Option<String>,
    pub type_: MessageType,
    pub bodies: BTreeMap<String, Body>,
    pub subjects: BTreeMap<String, Subject>,
    pub thread: Option<Thread>,
    pub payloads: Vec<Element>,
}

The main structure representing the <message/> stanza.

Fields

from: Option<Jid>

The JID emitting this stanza.

to: Option<Jid>

The recipient of this stanza.

id: Option<String>

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

type_: MessageType

The type of this message.

bodies: BTreeMap<String, Body>

A list of bodies, sorted per language. Use get_best_body() to access them on reception.

subjects: BTreeMap<String, Subject>

A list of subjects, sorted per language. Use get_best_subject() to access them on reception.

thread: Option<Thread>

An optional thread identifier, so that other people can reply directly to this message.

payloads: Vec<Element>

A list of the extension payloads contained in this stanza.

Methods

impl Message[src]

pub fn new(to: Option<Jid>) -> Message[src]

Creates a new <message/> stanza for the given recipient.

pub fn get_best_body(
    &self,
    preferred_langs: Vec<&str>
) -> Option<(String, &Body)>
[src]

Returns the best matching body from a list of languages.

For instance, if a message contains both an xml:lang='de', an xml:lang='fr' and an English body without an xml:lang attribute, and you pass ["fr", "en"] as your preferred languages, Some(("fr", the_second_body)) will be returned.

If no body matches, an undefined body will be returned.

pub fn get_best_subject(
    &self,
    preferred_langs: Vec<&str>
) -> Option<(String, &Subject)>
[src]

Returns the best matching subject from a list of languages.

For instance, if a message contains both an xml:lang='de', an xml:lang='fr' and an English subject without an xml:lang attribute, and you pass ["fr", "en"] as your preferred languages, Some(("fr", the_second_subject)) will be returned.

If no subject matches, an undefined subject will be returned.

Trait Implementations

impl From<Message> for Element[src]

impl Clone for Message[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Message[src]

impl TryFrom<Element> for Message[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl Unpin for Message

impl !Sync for Message

impl !Send for Message

impl !RefUnwindSafe for Message

impl !UnwindSafe for Message

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> IntoElements for T where
    T: Into<Element>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self