From 14ffc8db01e0f5f7155bf908315d22f5b7de23a0 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 4 Aug 2022 10:20:33 +0200 Subject: [PATCH] Change MessageAck message_id to be a &str While all the examples in RFC 5730 use numbers, there is nothing normative in section 2.9.2.3 that constrains msgID to be a number. And if we look at the XML Schema, we find that msgID is defined to be of type `token`, which seems to be defined as a string that does not contain line feeds, carriage returns, tabs, leading or trailing spaces or multiple spaces. While we might define a more specific token type in the future, for now sticking with just &str seems reasonable and this also matches the type for `MessageQueue::id`. --- src/message/ack.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/message/ack.rs b/src/message/ack.rs index 96f2d64..55fe57a 100644 --- a/src/message/ack.rs +++ b/src/message/ack.rs @@ -19,14 +19,14 @@ pub struct MessageAck<'a> { op: &'a str, /// The ID of the message to be acknowledged #[serde(rename = "msgID")] - message_id: String, + message_id: &'a str, } impl<'a> MessageAck<'a> { - pub fn new(message_id: u32) -> Self { + pub fn new(message_id: &'a str) -> Self { Self { op: "ack", - message_id: message_id.to_string(), + message_id, } } } @@ -39,7 +39,7 @@ mod tests { #[test] fn command() { - let object = MessageAck::new(12345); + let object = MessageAck::new("12345"); assert_serialized("request/message/ack.xml", &object); }