feat: implement Attachment

This commit is contained in:
RobWalt 2023-10-22 11:18:18 +02:00
parent 3951366142
commit 4973971996
No known key found for this signature in database
GPG key ID: 333C6AC0CEF0CE68

View file

@ -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<Utc>,
/// 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)
}
}