1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

use super::def::*;
use cyfs_base::*;

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MetaOutputRequestCommon {
    // 来源DEC
    pub dec_id: Option<ObjectId>,

    // 目标DEC
    pub target_dec_id: Option<ObjectId>,

    // 用以默认行为
    pub target: Option<ObjectId>,

    pub flags: u32,
}

impl MetaOutputRequestCommon {
    pub fn new() -> Self {
        Self {
            dec_id: None,
            target_dec_id: None,
            target: None,
            flags: 0,
        }
    }
}

impl std::fmt::Display for MetaOutputRequestCommon {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        if let Some(dec_id) = &self.dec_id {
            write!(f, "dec_id: {}", dec_id)?;
        }
        if let Some(target_dec_id) = &self.target_dec_id {
            write!(f, ", target_dec_id: {}", target_dec_id)?;
        }

        if let Some(target) = &self.target {
            write!(f, ", target: {}", target)?;
        }

        write!(f, ", flags: {}", self.flags)?;

        Ok(())
    }
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaAddAccessOutputRequest {
    pub common: MetaOutputRequestCommon,

    pub item: GlobalStatePathAccessItem,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaAddAccessOutputResponse {
    pub updated: bool,
}

pub type GlobalStateMetaRemoveAccessOutputRequest = GlobalStateMetaAddAccessOutputRequest;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaRemoveAccessOutputResponse {
    pub item: Option<GlobalStatePathAccessItem>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaClearAccessOutputRequest {
    pub common: MetaOutputRequestCommon,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaClearAccessOutputResponse {
    pub count: u32,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaAddLinkOutputRequest {
    pub common: MetaOutputRequestCommon,

    pub source: String,
    pub target: String,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaAddLinkOutputResponse {
    pub updated: bool,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaRemoveLinkOutputRequest {
    pub common: MetaOutputRequestCommon,

    pub source: String,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaRemoveLinkOutputResponse {
    pub item: Option<GlobalStatePathLinkItem>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaClearLinkOutputRequest {
    pub common: MetaOutputRequestCommon,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GlobalStateMetaClearLinkOutputResponse {
    pub count: u32,
}