message: Document this module, except for MessagePayload which should be removed.
This commit is contained in:
parent
b8f083eb0a
commit
d3890d21fb
1 changed files with 57 additions and 10 deletions
|
|
@ -107,34 +107,81 @@ impl From<MessagePayload> for Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_attribute!(MessageType, "type", {
|
generate_attribute!(
|
||||||
Chat => "chat",
|
/// The type of a message.
|
||||||
Error => "error",
|
MessageType, "type", {
|
||||||
Groupchat => "groupchat",
|
/// Standard instant messaging message.
|
||||||
Headline => "headline",
|
Chat => "chat",
|
||||||
Normal => "normal",
|
|
||||||
}, Default = Normal);
|
/// Notifies that an error happened.
|
||||||
|
Error => "error",
|
||||||
|
|
||||||
|
/// Standard group instant messaging message.
|
||||||
|
Groupchat => "groupchat",
|
||||||
|
|
||||||
|
/// Used by servers to notify users when things happen.
|
||||||
|
Headline => "headline",
|
||||||
|
|
||||||
|
/// This is an email-like message, it usually contains a
|
||||||
|
/// [subject](struct.Subject.html).
|
||||||
|
Normal => "normal",
|
||||||
|
}, Default = Normal
|
||||||
|
);
|
||||||
|
|
||||||
type Lang = String;
|
type Lang = String;
|
||||||
|
|
||||||
generate_elem_id!(Body, "body", DEFAULT_NS);
|
generate_elem_id!(
|
||||||
generate_elem_id!(Subject, "subject", DEFAULT_NS);
|
/// Represents one `<body/>` element, that is the free form text content of
|
||||||
generate_elem_id!(Thread, "thread", DEFAULT_NS);
|
/// a message.
|
||||||
|
Body, "body", DEFAULT_NS
|
||||||
|
);
|
||||||
|
|
||||||
|
generate_elem_id!(
|
||||||
|
/// Defines the subject of a room, or of an email-like normal message.
|
||||||
|
Subject, "subject", DEFAULT_NS
|
||||||
|
);
|
||||||
|
|
||||||
|
generate_elem_id!(
|
||||||
|
/// A thread identifier, so that other people can specify to which message
|
||||||
|
/// they are replying.
|
||||||
|
Thread, "thread", DEFAULT_NS
|
||||||
|
);
|
||||||
|
|
||||||
/// The main structure representing the `<message/>` stanza.
|
/// The main structure representing the `<message/>` stanza.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
|
/// The JID emitting this stanza.
|
||||||
pub from: Option<Jid>,
|
pub from: Option<Jid>,
|
||||||
|
|
||||||
|
/// The recipient of this stanza.
|
||||||
pub to: Option<Jid>,
|
pub to: Option<Jid>,
|
||||||
|
|
||||||
|
/// The @id attribute of this stanza, which is required in order to match a
|
||||||
|
/// request with its response.
|
||||||
pub id: Option<String>,
|
pub id: Option<String>,
|
||||||
|
|
||||||
|
/// The type of this message.
|
||||||
pub type_: MessageType,
|
pub type_: MessageType,
|
||||||
|
|
||||||
|
/// A list of bodies, sorted per language. Use
|
||||||
|
/// [get_best_body()](#method.get_best_body) to access them on reception.
|
||||||
pub bodies: BTreeMap<Lang, Body>,
|
pub bodies: BTreeMap<Lang, Body>,
|
||||||
|
|
||||||
|
/// A list of subjects, sorted per language. Use
|
||||||
|
/// [get_best_subject()](#method.get_best_subject) to access them on
|
||||||
|
/// reception.
|
||||||
pub subjects: BTreeMap<Lang, Subject>,
|
pub subjects: BTreeMap<Lang, Subject>,
|
||||||
|
|
||||||
|
/// An optional thread identifier, so that other people can reply directly
|
||||||
|
/// to this message.
|
||||||
pub thread: Option<Thread>,
|
pub thread: Option<Thread>,
|
||||||
|
|
||||||
|
/// A list of the extension payloads contained in this stanza.
|
||||||
pub payloads: Vec<Element>,
|
pub payloads: Vec<Element>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message {
|
impl Message {
|
||||||
|
/// Creates a new `<message/>` stanza for the given recipient.
|
||||||
pub fn new(to: Option<Jid>) -> Message {
|
pub fn new(to: Option<Jid>) -> Message {
|
||||||
Message {
|
Message {
|
||||||
from: None,
|
from: None,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue