Major refactor to handler traits
Added `IntoGiteratedHandler`, which is the new trait for handler functions. This allows us to finally get rid of the Object and ObjectOperation bounds that resulted in hacks around the newer features of the unified stack. Squashed commit of the following: commit 62e1ecf76ee31cda0bab4602d9d00fa0dc2f9158 Author: Amber <[email protected]> Date: Wed Oct 11 09:31:11 2023 -0500 Update commit dfd2d1b0b5d81ee3bc48f0321c6aceaa677e3b8b Author: Amber <[email protected]> Date: Wed Oct 11 09:31:07 2023 -0500 Major refactor to handler traits Added `IntoGiteratedHandler`, which is the new trait for handler functions. This allows us to finally get rid of the Object and ObjectOperation bounds that resulted in hacks around the newer features of the unified stack. Removed dead and legacy code. I think... commit 57b4b398eff32e69f2f4b9700e42a1277a4d1055 Author: Amber <[email protected]> Date: Sun Oct 1 23:05:10 2023 -0500 New handler trait for giterated stack Refactor the old handler trait so it is more generic and can be used for specific kinds of handlers
parent: tbd commit: 90c4780
1 | |
2 | |
3 | |
4 | use Any; |
5 | use Arc; |
6 | |
7 | use Context; |
8 | |
9 | use Instance; |
10 | use ; |
11 | use ; |
12 | use MetadataProvider; |
13 | use SettingMeta; |
14 | use ; |
15 | use Value; |
16 | use PgPool; |
17 | use Debug; |
18 | use ; |
19 | |
20 | use crate; |
21 | use crate; |
22 | |
23 | use |
24 | instance_authentication_request, instance_create_repository_request, |
25 | instance_registration_request, repository_commit_before, repository_commit_by_id, |
26 | repository_diff, repository_diff_patch, repository_file_from_id, repository_file_from_path, |
27 | repository_get_branches, repository_get_statistics, repository_info, |
28 | repository_last_commit_of_file, user_get_repositories, |
29 | ; |
30 | |
31 | /// A backend implementation which attempts to resolve data from the instance's database. |
32 | |
33 | |
34 | |
35 | pub(self) our_instance: Instance, |
36 | pub(self) pool: PgPool, |
37 | pub(self) user_backend: , |
38 | pub(self) repository_backend: , |
39 | pub stack: , |
40 | |
41 | |
42 | |
43 | |
44 | instance: Instance, |
45 | user_backend: , |
46 | repository_backend: , |
47 | pool: PgPool, |
48 | stack: , |
49 | |
50 | Self |
51 | our_instance: instance, |
52 | user_backend, |
53 | repository_backend, |
54 | pool, |
55 | stack, |
56 | |
57 | |
58 | |
59 | |
60 | let mut builder = new; |
61 | |
62 | builder.object_metadata_provider; |
63 | |
64 | builder |
65 | . |
66 | . |
67 | .; |
68 | |
69 | // Register value settings, which are settings that directly correspond to |
70 | // value types. |
71 | builder |
72 | . |
73 | . |
74 | . |
75 | . |
76 | .; |
77 | |
78 | builder |
79 | .operation |
80 | .operation |
81 | .operation |
82 | .operation |
83 | .operation |
84 | .operation |
85 | .operation |
86 | .operation |
87 | .operation |
88 | .operation |
89 | .operation |
90 | .operation |
91 | .operation |
92 | .operation; |
93 | |
94 | builder |
95 | |
96 | |
97 | |
98 | |
99 | |
100 | f.debug_struct .finish |
101 | |
102 | |
103 | |
104 | |
105 | |
106 | |
107 | object.|| object. || object. |
108 | |
109 | |
110 | async |
111 | &self, |
112 | object: AnyObject, |
113 | _object_meta: &ObjectMeta, |
114 | setting: AnySetting, |
115 | setting_meta: &SettingMeta, |
116 | |
117 | if let Some = object.0. |
118 | ! | query
119 | repository.to_string, setting_meta.name, to_string? |
120 | .execute .await?; |
121 | |
122 | Ok |
123 | else if let Some = object.0. |
124 | ! | query
125 | user.username, setting_meta.name, to_string? |
126 | .execute .await?; |
127 | |
128 | Ok |
129 | else |
130 | unreachable! |
131 | |
132 | |
133 | |
134 | async |
135 | &self, |
136 | object: AnyObject, |
137 | _object_meta: &ObjectMeta, |
138 | setting_meta: &SettingMeta, |
139 | |
140 | if let Some = object.0. |
141 | let row = query_as! |
142 | RepositorySettingRow, |
143 | "SELECT * FROM repository_settings WHERE repository = $1 AND name = $2", |
144 | repository.to_string, |
145 | setting_meta.name |
146 | |
147 | .fetch_one |
148 | .await?; |
149 | |
150 | let setting = |
151 | context?; | from_str .
152 | |
153 | Ok |
154 | else if let Some = object.0. |
155 | info!; |
156 | let row = query_as! |
157 | UserSettingRow, |
158 | "SELECT * FROM user_settings WHERE username = $1 AND name = $2", |
159 | user.username, |
160 | setting_meta.name |
161 | |
162 | .fetch_one |
163 | .await?; |
164 | |
165 | let setting = |
166 | context?; | from_str .
167 | |
168 | Ok |
169 | else |
170 | unreachable! |
171 | |
172 | |
173 | |
174 |