Message and message_correct::Replace now has typed Id

This commit is contained in:
xmppftw xmppftw 2024-12-21 00:10:13 +01:00 committed by pep
commit 33098e6f2c
9 changed files with 45 additions and 32 deletions

View file

@ -36,6 +36,14 @@ generate_attribute!(
type Lang = String;
generate_id!(
/// Id field in a [`Message`], if any.
///
/// This field is not mandatory on incoming messages, but may be useful for moderation/correction,
/// especially for outgoing messages.
Id
);
generate_elem_id!(
/// Represents one `<body/>` element, that is the free form text content of
/// a message.
@ -70,7 +78,7 @@ pub struct Message {
/// 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<Id>,
/// The type of this message.
pub type_: MessageType,

View file

@ -6,7 +6,7 @@
use xso::{AsXml, FromXml};
use crate::message::MessagePayload;
use crate::message::{Id, MessagePayload};
use crate::ns;
/// Defines that the message containing this payload should replace a
@ -16,7 +16,7 @@ use crate::ns;
pub struct Replace {
/// The 'id' attribute of the message getting corrected.
#[xml(attribute)]
pub id: String,
pub id: Id,
}
impl MessagePayload for Replace {}
@ -98,7 +98,7 @@ mod tests {
.parse()
.unwrap();
let replace = Replace {
id: String::from("coucou"),
id: Id(String::from("coucou")),
};
let elem2 = replace.into();
assert_eq!(elem, elem2);