Finish unified stack refactor.
Adds support for operation state, which will be used to pass authentication information around. Added generic backend that uses a channel to communicate with a typed backend.
parent: tbd commit: d15581c
1 | use ; |
2 | |
3 | use crate:: |
4 | , |
5 | , | Object
6 | , | ObjectBackend
7 | , | GiteratedOperation
8 | ; |
9 | |
10 | use |
11 | Commit, IssueLabel, Repository, RepositoryDiff, RepositoryFile, RepositoryIssue, |
12 | RepositoryTreeEntry, RepositoryView, |
13 | ; |
14 | |
15 | /// A request to get a repository's information. |
16 | /// |
17 | /// # Authentication |
18 | /// - Instance Authentication |
19 | /// - Validate request against the `issued_for` public key |
20 | /// - Validate User token against the user's instance's public key |
21 | /// # Authorization |
22 | /// - User Authorization |
23 | /// - Potential User permissions checks |
24 | |
25 | |
26 | pub extra_metadata: bool, |
27 | pub rev: , |
28 | pub path: , |
29 | |
30 | |
31 | |
32 | type Success = RepositoryView; |
33 | type Failure = RepositoryError; |
34 | |
35 | |
36 | /// A request to get a file from a repository using the given id. |
37 | /// |
38 | /// # Authentication |
39 | /// - Instance Authentication |
40 | /// - Validate request against the `issued_for` public key |
41 | /// - Validate User token against the user's instance's public key |
42 | /// # Authorization |
43 | /// - User Authorization |
44 | /// - Potential User permissions checks |
45 | |
46 | ; |
47 | |
48 | |
49 | type Success = RepositoryFile; |
50 | type Failure = RepositoryError; |
51 | |
52 | |
53 | /// A request to get the difference between two repository trees. |
54 | /// |
55 | /// # Authentication |
56 | /// - Instance Authentication |
57 | /// - Validate request against the `issued_for` public key |
58 | /// - Validate User token against the user's instance's public key |
59 | /// # Authorization |
60 | /// - User Authorization |
61 | /// - Potential User permissions checks |
62 | |
63 | |
64 | pub old_id: String, |
65 | pub new_id: String, |
66 | |
67 | |
68 | |
69 | type Success = RepositoryDiff; |
70 | type Failure = RepositoryError; |
71 | |
72 | |
73 | /// A request to get the commit before the one with the passed id |
74 | /// |
75 | /// # Authentication |
76 | /// - Instance Authentication |
77 | /// - Validate request against the `issued_for` public key |
78 | /// - Validate User token against the user's instance's public key |
79 | /// # Authorization |
80 | /// - User Authorization |
81 | /// - Potential User permissions checks |
82 | |
83 | ; |
84 | |
85 | |
86 | type Success = Commit; |
87 | type Failure = RepositoryError; |
88 | |
89 | |
90 | |
91 | ; |
92 | |
93 | |
94 | type Success = u64; |
95 | type Failure = RepositoryError; |
96 | |
97 | |
98 | /// A request to get a repository's issues count. |
99 | /// |
100 | /// # Authentication |
101 | /// - Instance Authentication |
102 | /// - Validate request against the `issued_for` public key |
103 | /// - Validate User token against the user's instance's public key |
104 | /// # Authorization |
105 | /// - User Authorization |
106 | /// - Potential User permissions checks |
107 | |
108 | ; |
109 | |
110 | |
111 | type Success = ; |
112 | type Failure = RepositoryError; |
113 | |
114 | |
115 | /// A request to get a repository's issue labels. |
116 | /// |
117 | /// # Authentication |
118 | /// - Instance Authentication |
119 | /// - Validate request against the `issued_for` public key |
120 | /// - Validate User token against the user's instance's public key |
121 | /// # Authorization |
122 | /// - User Authorization |
123 | /// - Potential User permissions checks |
124 | |
125 | ; |
126 | |
127 | |
128 | type Success = ; |
129 | type Failure = RepositoryError; |
130 | |
131 | |
132 | /// A request to inspect the tree of a repository. |
133 | /// |
134 | /// # Authentication |
135 | /// - Instance Authentication |
136 | /// - Validate request against the `issued_for` public key |
137 | /// - Validate User token against the user's instance's public key |
138 | /// # Authorization |
139 | /// - User Authorization |
140 | /// - Potential User permissions checks |
141 | |
142 | |
143 | /// Whether to get extra metadata for every entry (file mode, size and last commit made to it). |
144 | pub extra_metadata: bool, |
145 | /// Revision of the repository to get (branch, commit id). |
146 | pub rev: , |
147 | /// If not given a path, it'll default to the base. |
148 | pub path: , |
149 | |
150 | |
151 | |
152 | type Success = ; |
153 | type Failure = RepositoryError; |
154 | |
155 | |
156 | |
157 | pub async |
158 | &mut self, |
159 | extra_metadata: bool, |
160 | rev: , |
161 | path: , |
162 | operation_state: &S, |
163 | |
164 | self. |
165 | RepositoryInfoRequest |
166 | extra_metadata, |
167 | rev, |
168 | path, |
169 | , |
170 | operation_state, |
171 | |
172 | .await |
173 | |
174 | |
175 | pub async |
176 | &mut self, |
177 | id: String, |
178 | operation_state: &S, |
179 | |
180 | self. |
181 | RepositoryFileFromIdRequest, |
182 | operation_state, |
183 | |
184 | .await |
185 | |
186 | |
187 | pub async |
188 | &mut self, |
189 | old_id: String, |
190 | new_id: String, |
191 | operation_state: &S, |
192 | |
193 | self. |
194 | RepositoryDiffRequest , |
195 | operation_state, |
196 | |
197 | .await |
198 | |
199 | |
200 | pub async |
201 | &mut self, |
202 | id: String, |
203 | operation_state: &S, |
204 | |
205 | self. |
206 | RepositoryCommitBeforeRequest, |
207 | operation_state, |
208 | |
209 | .await |
210 | |
211 | |
212 | // pub async fn issues_count(&mut self) -> Result<u64, OperationError<RepositoryError>> { |
213 | // self.request::<RepositoryIssuesCountRequest>(RepositoryIssuesCountRequest) |
214 | // .await |
215 | // } |
216 | |
217 | pub async |
218 | &mut self, |
219 | operation_state: &S, |
220 | |
221 | self. |
222 | .await |
223 | |
224 | |
225 | pub async |
226 | &mut self, |
227 | operation_state: &S, |
228 | |
229 | self. |
230 | .await |
231 | |
232 | |
233 | pub async |
234 | &mut self, |
235 | extra_metadata: bool, |
236 | rev: , |
237 | path: , |
238 | operation_state: &S, |
239 | |
240 | self. |
241 | RepositoryFileInspectRequest |
242 | extra_metadata, |
243 | rev: rev.map, |
244 | path: path.map, |
245 | , |
246 | operation_state, |
247 | |
248 | .await |
249 | |
250 | |
251 |