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

ambee/giterated

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

Initial git handling

Type: Feature

emilia - ⁨2⁩ years ago

parent: tbd commit: ⁨523decf

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