nextcloud_users/capabilities/
files.rs1use serde::{Deserialize, Serialize};
2
3use super::ChunkedUpload;
4use crate::wire::{lossy_bool, lossy_opt_u64};
5
6#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
8pub struct FilesCapabilities {
9 #[serde(
11 default,
12 alias = "bigfilechunking",
13 alias = "big_file_chunking",
14 deserialize_with = "lossy_bool"
15 )]
16 pub big_file_chunking: bool,
17 #[serde(default, deserialize_with = "lossy_bool")]
19 pub undelete: bool,
20 #[serde(default, deserialize_with = "lossy_bool")]
22 pub versioning: bool,
23 #[serde(default, alias = "chunked_upload", alias = "chunkedUpload")]
25 pub chunked_upload: Option<ChunkedUpload>,
26 #[serde(
28 default,
29 alias = "max_chunk_size",
30 alias = "maxChunkSize",
31 deserialize_with = "lossy_opt_u64"
32 )]
33 pub max_chunk_size: Option<u64>,
34}
35
36impl FilesCapabilities {
37 pub const fn big_file_chunking(&self) -> bool {
39 self.big_file_chunking
40 }
41
42 pub const fn undelete(&self) -> bool {
44 self.undelete
45 }
46
47 pub const fn versioning(&self) -> bool {
49 self.versioning
50 }
51
52 pub fn chunked_upload(&self) -> Option<&ChunkedUpload> {
54 self.chunked_upload.as_ref()
55 }
56
57 pub fn max_chunk_size(&self) -> Option<u64> {
60 self.max_chunk_size
61 .or_else(|| self.chunked_upload.as_ref().and_then(|c| c.max_size))
62 }
63}