revolt_models/v0/
files.rs

1auto_derived!(
2    /// File
3    pub struct File {
4        /// Unique Id
5        #[cfg_attr(feature = "serde", serde(rename = "_id"))]
6        pub id: String,
7        /// Tag / bucket this file was uploaded to
8        pub tag: String,
9        /// Original filename
10        pub filename: String,
11        /// Parsed metadata of this file
12        pub metadata: Metadata,
13        /// Raw content type of this file
14        pub content_type: String,
15        /// Size of this file (in bytes)
16        pub size: isize,
17
18        /// Whether this file was deleted
19        #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
20        pub deleted: Option<bool>,
21        /// Whether this file was reported
22        #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
23        pub reported: Option<bool>,
24
25        // TODO: migrate this mess to having:
26        // - author_id
27        // - parent: Parent { Message(id), User(id), etc }
28        #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
29        pub message_id: Option<String>,
30        #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
31        pub user_id: Option<String>,
32        #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
33        pub server_id: Option<String>,
34
35        /// Id of the object this file is associated with
36        #[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
37        pub object_id: Option<String>,
38    }
39
40    /// Metadata associated with a file
41    #[cfg_attr(feature = "serde", serde(tag = "type"))]
42    #[derive(Default)]
43    pub enum Metadata {
44        /// File is just a generic uncategorised file
45        #[default]
46        File,
47        /// File contains textual data and should be displayed as such
48        Text,
49        /// File is an image with specific dimensions
50        Image { width: usize, height: usize },
51        /// File is a video with specific dimensions
52        Video { width: usize, height: usize },
53        /// File is audio
54        Audio,
55    }
56);