JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Add more backend logic

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨5060ca2

⁨src/backend/mod.rs⁩ - ⁨2316⁩ bytes
Raw
1 pub mod git;
2 pub mod github;
3
4 use std::error::Error;
5
6 use crate::{
7 messages::{
8 repository::{
9 CreateRepositoryRequest, CreateRepositoryResponse, RepositoryFileInspectRequest,
10 RepositoryFileInspectionResponse, RepositoryInfoRequest, RepositoryIssueLabelsRequest,
11 RepositoryIssueLabelsResponse, RepositoryIssuesCountRequest,
12 RepositoryIssuesCountResponse, RepositoryIssuesRequest, RepositoryIssuesResponse,
13 },
14 user::{
15 UserBioRequest, UserBioResponse, UserDisplayImageRequest, UserDisplayImageResponse,
16 UserDisplayNameRequest, UserDisplayNameResponse,
17 },
18 },
19 model::repository::RepositoryView,
20 };
21
22 pub trait RepositoryBackend: IssuesBackend {
23 fn create_repository(
24 &mut self,
25 request: &CreateRepositoryRequest,
26 ) -> Result<CreateRepositoryResponse, Box<dyn Error + Send>>;
27 fn repository_info(
28 &mut self,
29 request: &RepositoryInfoRequest,
30 ) -> Result<RepositoryView, Box<dyn Error + Send>>;
31 fn repository_file_inspect(
32 &mut self,
33 request: &RepositoryFileInspectRequest,
34 ) -> Result<RepositoryFileInspectionResponse, Box<dyn Error + Send>>;
35 }
36
37 pub trait IssuesBackend {
38 fn issues_count(
39 &mut self,
40 request: &RepositoryIssuesCountRequest,
41 ) -> Result<RepositoryIssuesCountResponse, Box<dyn Error + Send>>;
42 fn issue_labels(
43 &mut self,
44 request: &RepositoryIssueLabelsRequest,
45 ) -> Result<RepositoryIssueLabelsResponse, Box<dyn Error + Send>>;
46 fn issues(
47 &mut self,
48 request: &RepositoryIssuesRequest,
49 ) -> Result<RepositoryIssuesResponse, Box<dyn Error + Send>>;
50 }
51
52 pub trait AuthBackend {
53 fn register(&mut self, request: ()) -> Result<(), Box<dyn Error + Send>>;
54
55 fn login(&mut self, request: ()) -> Result<(), Box<dyn Error + Send>>;
56 }
57
58 pub trait UserBackend {
59 fn display_name(
60 &mut self,
61 request: UserDisplayNameRequest,
62 ) -> Result<UserDisplayNameResponse, Box<dyn Error + Send>>;
63
64 fn display_image(
65 &mut self,
66 request: UserDisplayImageRequest,
67 ) -> Result<UserDisplayImageResponse, Box<dyn Error + Send>>;
68
69 fn bio(&mut self, request: UserBioRequest) -> Result<UserBioResponse, Box<dyn Error + Send>>;
70 }
71