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

ambee/giterated

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

Add token extension

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨86d028f

⁨src/backend/mod.rs⁩ - ⁨2419⁩ 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 UserAuthenticated,
20 },
21 model::repository::RepositoryView,
22 };
23
24 #[async_trait]
25 pub trait RepositoryBackend: IssuesBackend {
26 async fn create_repository(
27 &mut self,
28 request: &UserAuthenticated<CreateRepositoryRequest>,
29 ) -> Result<CreateRepositoryResponse, Box<dyn Error + Send>>;
30 async fn repository_info(
31 &mut self,
32 request: &RepositoryInfoRequest,
33 ) -> Result<RepositoryView, Box<dyn Error + Send>>;
34 fn repository_file_inspect(
35 &mut self,
36 request: &RepositoryFileInspectRequest,
37 ) -> Result<RepositoryFileInspectionResponse, Box<dyn Error + Send>>;
38 }
39
40 pub trait IssuesBackend {
41 fn issues_count(
42 &mut self,
43 request: &RepositoryIssuesCountRequest,
44 ) -> Result<RepositoryIssuesCountResponse, Box<dyn Error + Send>>;
45 fn issue_labels(
46 &mut self,
47 request: &RepositoryIssueLabelsRequest,
48 ) -> Result<RepositoryIssueLabelsResponse, Box<dyn Error + Send>>;
49 fn issues(
50 &mut self,
51 request: &RepositoryIssuesRequest,
52 ) -> Result<RepositoryIssuesResponse, Box<dyn Error + Send>>;
53 }
54
55 pub trait AuthBackend {
56 fn register(&mut self, request: ()) -> Result<(), Box<dyn Error + Send>>;
57
58 fn login(&mut self, request: ()) -> Result<(), Box<dyn Error + Send>>;
59 }
60
61 pub trait UserBackend {
62 fn display_name(
63 &mut self,
64 request: UserDisplayNameRequest,
65 ) -> Result<UserDisplayNameResponse, Box<dyn Error + Send>>;
66
67 fn display_image(
68 &mut self,
69 request: UserDisplayImageRequest,
70 ) -> Result<UserDisplayImageResponse, Box<dyn Error + Send>>;
71
72 fn bio(&mut self, request: UserBioRequest) -> Result<UserBioResponse, Box<dyn Error + Send>>;
73 }
74