cloudreve_api/api/v4/models/
file.rs1use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Serialize, Deserialize, Clone)]
8pub struct File {
9 #[serde(rename = "type")]
10 pub r#type: FileType,
11 pub id: String,
12 pub name: String,
13 #[serde(default)]
14 pub permission: Option<String>,
15 pub created_at: String,
16 pub updated_at: String,
17 pub size: i64,
18 #[serde(default)]
19 pub metadata: Option<Value>,
20 pub path: String,
21 #[serde(default)]
22 pub capability: Option<String>,
23 pub owned: bool,
24 #[serde(default)]
25 pub primary_entity: Option<String>,
26}
27
28#[derive(Debug, Serialize, Clone, PartialEq)]
30pub enum FileType {
31 File = 0,
32 Folder = 1,
33}
34
35impl<'de> Deserialize<'de> for FileType {
36 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
37 where
38 D: serde::Deserializer<'de>,
39 {
40 let value = i32::deserialize(deserializer)?;
41 match value {
42 0 => Ok(FileType::File),
43 1 => Ok(FileType::Folder),
44 _ => Err(serde::de::Error::custom(format!(
45 "Invalid FileType value: {}",
46 value
47 ))),
48 }
49 }
50}
51
52#[derive(Debug, Serialize, Deserialize)]
54pub struct FileStat {
55 pub size: u64,
56 pub created_at: String,
57 pub updated_at: String,
58 pub mime_type: String,
59}
60
61#[derive(Debug, Serialize, Deserialize, Clone)]
63pub struct ListResponse {
64 pub files: Vec<File>,
65 pub parent: File,
66 pub pagination: PaginationResults,
67 pub props: NavigatorProps,
68 pub context_hint: String,
69 pub mixed_type: bool,
70 #[serde(default)]
71 pub storage_policy: Option<super::storage::StoragePolicy>,
72 pub view: Option<ExplorerView>,
73}
74
75#[derive(Debug, Serialize, Deserialize, Clone)]
77pub struct PaginationResults {
78 pub page: i32,
79 pub page_size: i32,
80 pub total_items: Option<i64>,
81 pub next_token: Option<String>,
82 pub is_cursor: bool,
83}
84
85#[derive(Debug, Serialize, Deserialize, Clone)]
87pub struct NavigatorProps {
88 pub capability: String,
89 pub max_page_size: i32,
90 pub order_by_options: Vec<String>,
91 pub order_direction_options: Vec<String>,
92}
93
94#[derive(Debug, Serialize, Deserialize, Clone)]
96pub struct ExplorerView {
97 pub page_size: Option<i32>,
98 pub order: Option<String>,
99 pub order_direction: Option<OrderDirection>,
100 pub view: Option<ExplorerViewMode>,
101 pub thumbnail: Option<bool>,
102 pub gallery_width: Option<i32>,
103 pub columns: Option<Vec<ListViewColumn>>,
104}
105
106#[derive(Debug, Serialize, Deserialize, Clone)]
108pub enum OrderDirection {
109 #[serde(rename = "asc")]
110 Asc,
111 #[serde(rename = "desc")]
112 Desc,
113}
114
115#[derive(Debug, Serialize, Deserialize, Clone)]
117pub enum ExplorerViewMode {
118 #[serde(rename = "list")]
119 List,
120 #[serde(rename = "grid")]
121 Grid,
122 #[serde(rename = "gallery")]
123 Gallery,
124}
125
126#[derive(Debug, Serialize, Deserialize, Clone)]
128pub struct ListViewColumn {
129 pub r#type: i32,
130 pub width: Option<i32>,
131 pub props: Option<ColumnProps>,
132}
133
134#[derive(Debug, Serialize, Deserialize, Clone)]
136pub struct ColumnProps {
137 pub metadata_key: Option<String>,
138}
139
140#[derive(Debug, Serialize, Deserialize, Clone)]
142pub struct ExtendedInfo {
143 #[serde(default)]
144 pub storage_policy: Option<super::storage::NewStoragePolicy>,
145 pub storage_policy_inherited: bool,
146 pub storage_used: i64,
147 #[serde(default)]
148 pub shares: Option<Vec<super::share::ShareLink>>,
149 #[serde(default)]
150 pub entities: Option<Vec<super::storage::NewEntity>>,
151 pub permissions: Option<PermissionSetting>,
152 #[serde(default)]
153 pub direct_links: Option<Vec<super::storage::DirectLink>>,
154}
155
156#[derive(Debug, Serialize, Deserialize, Clone)]
158pub struct FolderSummary {
159 pub size: i64,
160 pub files: i64,
161 pub folders: i64,
162 pub completed: bool,
163 pub calculated_at: String,
164}
165
166#[derive(Debug, Serialize, Deserialize, Clone)]
168pub struct PermissionSetting {
169 #[serde(rename = "user_explicit")]
170 pub user_explicit: Value,
171 #[serde(rename = "group_explicit")]
172 pub group_explicit: Value,
173 #[serde(rename = "same_group")]
174 pub same_group: String,
175 #[serde(rename = "other")]
176 pub other: String,
177 #[serde(rename = "anonymous")]
178 pub anonymous: String,
179 #[serde(rename = "everyone")]
180 pub everyone: String,
181}