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

ambee/giterated

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

Add docs

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨51aad53

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