rive_models/attachment.rs
1use serde::Deserialize;
2
3/// Metadata associated with attachment
4#[derive(Deserialize, Debug, Clone, Default)]
5#[serde(tag = "type")]
6pub enum AttachmentMetadata {
7 /// Attachment is just a generic uncategorised file
8 #[default]
9 File,
10
11 /// Attachment contains textual data and should be displayed as such
12 Text,
13
14 /// Attachment is an image with specific dimensions
15 Image { width: isize, height: isize },
16
17 /// Attachment is a video with specific dimensions
18 Video { width: isize, height: isize },
19
20 /// Attachment is audio
21 Audio,
22}
23
24/// Representation of an attachment on Revolt
25#[derive(Deserialize, Debug, Clone)]
26pub struct Attachment {
27 /// Unique Id
28 #[serde(rename = "_id")]
29 pub id: String,
30
31 /// Tag/bucket this attachment was uploaded to
32 pub tag: String,
33
34 /// Original filename
35 pub filename: String,
36
37 /// Parsed metadata of this attachment
38 pub metadata: AttachmentMetadata,
39
40 /// Raw content type of this attachment
41 pub content_type: String,
42
43 /// Size of this attachment (in bytes)
44 pub size: isize,
45
46 /// Whether this attachment was deleted
47 pub deleted: Option<bool>,
48
49 /// Whether this attachment was reported
50 pub reported: Option<bool>,
51
52 // NOTE: Theese 3 fields will be deprecated in the next update
53 pub message_id: Option<String>,
54 pub user_id: Option<String>,
55 pub server_id: Option<String>,
56
57 /// ID of the object this attachment is associated with
58 pub object_id: Option<String>,
59}