1use super::output_request::*;
2use crate::base::*;
3use crate::non::*;
4use cyfs_base::*;
5
6use std::fmt;
7
8#[derive(Debug, Clone)]
9pub struct CryptoInputRequestCommon {
10 pub req_path: Option<String>,
12
13 pub source: RequestSourceInfo,
14
15 pub target: Option<ObjectId>,
17
18 pub flags: u32,
19}
20
21impl fmt::Display for CryptoInputRequestCommon {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 write!(f, "req_path: {:?}", self.req_path)?;
24 write!(f, ", {}", self.source)?;
25
26 if let Some(target) = &self.target {
27 write!(f, ", target: {}", target.to_string())?;
28 }
29
30 write!(f, ", flags: {}", self.flags)?;
31
32 Ok(())
33 }
34}
35
36#[derive(Debug, Clone)]
37pub struct CryptoSignObjectInputRequest {
38 pub common: CryptoInputRequestCommon,
39
40 pub object: NONObjectInfo,
41
42 pub flags: u32,
43}
44
45impl fmt::Display for CryptoSignObjectInputRequest {
46 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47 write!(f, "common: {}", self.common)?;
48 write!(f, ", object: {}", self.object)?;
49
50 write!(f, ", flags: {}", self.flags)
51 }
52}
53
54pub type CryptoSignObjectInputResponse = CryptoSignObjectOutputResponse;
55
56#[derive(Debug, Clone)]
57pub struct CryptoVerifyObjectInputRequest {
58 pub common: CryptoInputRequestCommon,
59
60 pub sign_type: VerifySignType,
62
63 pub object: NONObjectInfo,
65
66 pub sign_object: VerifyObjectType,
68}
69
70impl fmt::Display for CryptoVerifyObjectInputRequest {
71 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
72 write!(f, "common: {}", self.common)?;
73
74 write!(f, ", object: {}", self.object)?;
75 write!(f, ", sign_type: {:?}", self.sign_type)?;
76 write!(f, ", sign_object: {:?}", self.sign_object)
77 }
78}
79
80pub type CryptoVerifyObjectInputResponse = CryptoVerifyObjectOutputResponse;
81
82#[derive(Debug, Clone)]
83pub struct CryptoEncryptDataInputRequest {
84 pub common: CryptoInputRequestCommon,
85
86 pub encrypt_type: CryptoEncryptType,
87
88 pub data: Option<Vec<u8>>,
89
90 pub flags: u32,
91}
92
93impl CryptoEncryptDataInputRequest {
94 pub fn data_len(&self) -> usize {
95 match &self.data {
96 Some(data) => data.len(),
97 None => 0,
98 }
99 }
100}
101
102impl fmt::Display for CryptoEncryptDataInputRequest {
103 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104 write!(f, "common: {}", self.common)?;
105
106 write!(f, ", encrypt_type: {}", self.encrypt_type.as_str())?;
107 write!(
108 f,
109 ", data: {}",
110 match &self.data {
111 Some(data) => data.len(),
112 None => 0,
113 }
114 )?;
115 write!(f, ", flags: {}", self.flags)
116 }
117}
118
119pub type CryptoEncryptDataInputResponse = CryptoEncryptDataOutputResponse;
120
121#[derive(Debug, Clone)]
122pub struct CryptoDecryptDataInputRequest {
123 pub common: CryptoInputRequestCommon,
124
125 pub decrypt_type: CryptoDecryptType,
126
127 pub data: Vec<u8>,
128
129 pub flags: u32,
130}
131
132impl fmt::Display for CryptoDecryptDataInputRequest {
133 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
134 write!(f, "common: {}", self.common)?;
135
136 write!(f, ", decrypt_type: {}", self.decrypt_type.as_str())?;
137 write!(f, ", data: {}", self.data.len(),)?;
138 write!(f, ", flags: {}", self.flags)
139 }
140}
141
142pub type CryptoDecryptDataInputResponse = CryptoDecryptDataOutputResponse;