pub mod discovery; pub mod git; pub mod github; pub mod user; use anyhow::Error; use async_trait::async_trait; use crate::{ messages::{ authentication::{ AuthenticationTokenRequest, AuthenticationTokenResponse, RegisterAccountRequest, RegisterAccountResponse, }, discovery::DiscoveryMessage, repository::{ CreateRepositoryRequest, CreateRepositoryResponse, RepositoryFileInspectRequest, RepositoryFileInspectionResponse, RepositoryInfoRequest, RepositoryIssueLabelsRequest, RepositoryIssueLabelsResponse, RepositoryIssuesCountRequest, RepositoryIssuesCountResponse, RepositoryIssuesRequest, RepositoryIssuesResponse, }, user::{ UserBioRequest, UserBioResponse, UserDisplayImageRequest, UserDisplayImageResponse, UserDisplayNameRequest, UserDisplayNameResponse, }, ValidatedUserAuthenticated, }, model::repository::{Repository, RepositoryView}, }; #[async_trait] pub trait RepositoryBackend: IssuesBackend { async fn create_repository( &mut self, request: &ValidatedUserAuthenticated, ) -> Result; async fn repository_info( &mut self, request: &ValidatedUserAuthenticated, ) -> Result; fn repository_file_inspect( &mut self, request: &ValidatedUserAuthenticated, ) -> Result; } pub trait IssuesBackend { fn issues_count( &mut self, request: &ValidatedUserAuthenticated, ) -> Result; fn issue_labels( &mut self, request: &ValidatedUserAuthenticated, ) -> Result; fn issues( &mut self, request: &ValidatedUserAuthenticated, ) -> Result; } #[async_trait::async_trait] pub trait AuthBackend { async fn register( &mut self, request: RegisterAccountRequest, ) -> Result; async fn login( &mut self, request: AuthenticationTokenRequest, ) -> Result; } #[async_trait::async_trait] pub trait UserBackend: AuthBackend { async fn display_name( &mut self, request: UserDisplayNameRequest, ) -> Result; async fn display_image( &mut self, request: UserDisplayImageRequest, ) -> Result; async fn bio(&mut self, request: UserBioRequest) -> Result; } #[async_trait::async_trait] pub trait DiscoveryBackend { async fn try_handle(&mut self, request: &DiscoveryMessage) -> Result; async fn search(&mut self, search: &str) -> Result, Error>; }