lib: Export attention as a MessagePayload.

This commit is contained in:
Emmanuel Gil Peyrot 2017-04-21 01:56:18 +01:00
parent 458099cef0
commit 9410b9682a

View file

@ -54,9 +54,11 @@ pub enum MessagePayload {
Body(body::Body), Body(body::Body),
ChatState(chatstates::ChatState), ChatState(chatstates::ChatState),
Receipt(receipts::Receipt), Receipt(receipts::Receipt),
Attention(attention::Attention),
} }
/// Parse one of the payloads of a `<message/>` element, and return `Some` of a `MessagePayload` if parsing it succeeded, `None` otherwise. /// Parse one of the payloads of a `<message/>` element, and return `Some` of a
/// `MessagePayload` if parsing it succeeded, `None` otherwise.
pub fn parse_message_payload(elem: &Element) -> Option<MessagePayload> { pub fn parse_message_payload(elem: &Element) -> Option<MessagePayload> {
if let Ok(body) = body::parse_body(elem) { if let Ok(body) = body::parse_body(elem) {
Some(MessagePayload::Body(body)) Some(MessagePayload::Body(body))
@ -64,6 +66,8 @@ pub fn parse_message_payload(elem: &Element) -> Option<MessagePayload> {
Some(MessagePayload::ChatState(chatstate)) Some(MessagePayload::ChatState(chatstate))
} else if let Ok(receipt) = receipts::parse_receipt(elem) { } else if let Ok(receipt) = receipts::parse_receipt(elem) {
Some(MessagePayload::Receipt(receipt)) Some(MessagePayload::Receipt(receipt))
} else if let Ok(attention) = attention::parse_attention(elem) {
Some(MessagePayload::Attention(attention))
} else { } else {
None None
} }