From 49739719963543afe482f6e4c6c47abd449d7ced Mon Sep 17 00:00:00 2001 From: RobWalt Date: Sun, 22 Oct 2023 11:18:18 +0200 Subject: [PATCH] feat: implement Attachment --- src/types/api/attachment.rs | 44 +++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/types/api/attachment.rs b/src/types/api/attachment.rs index 22b400b..3f0b8b1 100644 --- a/src/types/api/attachment.rs +++ b/src/types/api/attachment.rs @@ -1,14 +1,30 @@ -// [ -// x-go-name: Attachments -// Attachment{ -// description: -// Attachment a generic attachment -// -// browser_download_url string -// created_at string($date-time) -// download_count integer($int64) -// id integer($int64) -// name string -// size integer($int64) -// uuid string -// }] +use std::fmt::Display; + +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use url::Url; + +/// Represents a generic attachment. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct Attachment { + /// The browser download URL of the attachment. + pub browser_download_url: Url, + /// The date and time when the attachment was created. + pub created_at: DateTime, + /// The number of times the attachment has been downloaded. + pub download_count: usize, + /// The unique identifier of the attachment. + pub id: usize, + /// The name of the attachment. + pub name: String, + /// The size of the attachment in bytes. + pub size: usize, + /// The UUID of the attachment. + pub uuid: String, +} + +impl Display for Attachment { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.name) + } +}