1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4use super::{
5 access_info::{EncryptedFolderAccessKey, UserAccessInfo},
6 file_metadata::{DocumentHmac, FileType, Owner},
7 secret_filename::SecretFileName,
8};
9
10#[derive(Serialize, Deserialize, Clone, Debug)]
11pub enum Meta {
12 V1 {
13 id: Uuid,
14 file_type: FileType,
15 parent: Uuid,
16 name: SecretFileName,
17 owner: Owner,
18 is_deleted: bool,
19 doc_size: Option<usize>,
20 doc_hmac: Option<DocumentHmac>,
21 user_access_keys: Vec<UserAccessInfo>,
22 folder_access_key: EncryptedFolderAccessKey,
23 },
24}
25
26impl Meta {
27 pub fn doc_size(&self) -> &Option<usize> {
28 match self {
29 Meta::V1 { doc_size, .. } => doc_size,
30 }
31 }
32}
33
34impl PartialEq for Meta {
36 fn eq(&self, other: &Self) -> bool {
37 match (self, other) {
38 (
39 Meta::V1 {
40 id,
41 file_type,
42 parent,
43 name,
44 owner,
45 is_deleted,
46 doc_hmac,
47 user_access_keys,
48 folder_access_key: _,
50 doc_size,
51 },
52 Meta::V1 {
53 id: other_id,
54 file_type: other_file_type,
55 parent: other_parent,
56 name: other_name,
57 owner: other_owner,
58 is_deleted: other_is_deleted,
59 doc_hmac: other_doc_hmac,
60 user_access_keys: other_user_access_keys,
61 folder_access_key: _other_folder_access_key,
63 doc_size: other_doc_size,
64 },
65 ) => {
66 id == other_id
67 && file_type == other_file_type
68 && parent == other_parent
69 && name == other_name
70 && owner == other_owner
71 && is_deleted == other_is_deleted
72 && doc_hmac == other_doc_hmac
73 && user_access_keys == other_user_access_keys
74 && doc_size == other_doc_size
75 }
76 }
77 }
78}