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