Add ID type for attachments

This commit is contained in:
D. Scott Boggs 2023-01-09 07:45:08 -05:00 committed by Scott Boggs
parent 547d994d13
commit 9f4327f546
1 changed files with 11 additions and 1 deletions

View File

@ -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<String>,
}
/// Wrapper type for a attachment ID string
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(transparent)]
pub struct AttachmentId(String);
impl AsRef<str> for AttachmentId {
fn as_ref(&self) -> &str {
&self.0
}
}
/// Information about the attachment itself.
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]