From 9f4327f546fc26f3a69dee16ab617ba13d5c86df Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Mon, 9 Jan 2023 07:45:08 -0500 Subject: [PATCH] Add ID type for attachments --- entities/src/attachment.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/entities/src/attachment.rs b/entities/src/attachment.rs index fa8a781..f34ffb6 100644 --- a/entities/src/attachment.rs +++ b/entities/src/attachment.rs @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] pub struct Attachment { /// ID of the attachment. - pub id: String, + pub id: AttachmentId, /// The media type of an attachment. #[serde(rename = "type")] pub media_type: MediaType, @@ -24,6 +24,16 @@ pub struct Attachment { /// Noop will be removed. pub description: Option, } +/// Wrapper type for a attachment ID string +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[serde(transparent)] +pub struct AttachmentId(String); + +impl AsRef for AttachmentId { + fn as_ref(&self) -> &str { + &self.0 + } +} /// Information about the attachment itself. #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]