cyfs_lib/acl/handler/
request.rs

1use super::super::{AclAccess, AclAction};
2use crate::base::*;
3use crate::ndn::*;
4use crate::non::NONSlimObjectInfo;
5use cyfs_base::*;
6
7pub struct AclHandlerRequest {
8    // 来源协议
9    pub protocol: RequestProtocol,
10
11    // 动作
12    pub action: AclAction,
13
14    // source/target
15    pub device_id: DeviceId,
16
17    // 操作对象
18    pub object: Option<NONSlimObjectInfo>,
19    pub inner_path: Option<String>,
20
21    // 所属dec
22    pub dec_id: String,
23
24    // 请求的path
25    pub req_path: Option<String>,
26
27    // 引用对象
28    pub referer_object: Option<Vec<NDNDataRefererObject>>,
29}
30
31impl std::fmt::Display for AclHandlerRequest {
32    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
33        write!(f, "protocol: {:?}", self.protocol)?;
34        write!(f, ", action: {:?}", self.action)?;
35        write!(f, ", device: {}", self.device_id)?;
36
37        if let Some(object) = &self.object {
38            write!(f, ", object: {:?}", object)?;
39        }
40
41        if let Some(inner_path) = &self.inner_path {
42            write!(f, ", inner_path: {}", inner_path)?;
43        }
44
45        write!(f, ", dec: {}", self.dec_id)?;
46        write!(f, ", req_path: {:?}", self.req_path)?;
47        if let Some(referer_object) = &self.referer_object {
48            write!(f, ", referer_object: {:?}", referer_object)?;
49        }
50
51        Ok(())
52    }
53}
54
55#[derive(Debug, Clone)]
56pub struct AclHandlerResponse {
57    pub access: AclAccess,
58}
59
60impl std::fmt::Display for AclHandlerResponse {
61    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
62        write!(f, "access: {:?}", self.access)
63    }
64}