Add wrapper around repository backend error
This commit is contained in:
@@ -10,7 +10,7 @@ pub trait RepositoryProvider {
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
async fn get(&self) -> Result<Self::Repository<'_>, Self::BackendError>;
|
||||
async fn get(&self) -> Result<Self::Repository<'_>, RepositoryError<Self::BackendError>>;
|
||||
}
|
||||
|
||||
pub trait Repository
|
||||
@@ -19,3 +19,6 @@ where
|
||||
{
|
||||
type BackendError: std::error::Error;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RepositoryError<E>(pub E);
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
use super::RepositoryError;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait UserRepository {
|
||||
type BackendError: std::error::Error;
|
||||
|
||||
async fn user(&mut self, id: i32) -> Result<Option<User>, Self::BackendError>;
|
||||
async fn user(&mut self, id: i32) -> Result<Option<User>, RepositoryError<Self::BackendError>>;
|
||||
|
||||
async fn insert_user(&mut self, new_user: NewUser) -> Result<User, Self::BackendError>;
|
||||
async fn insert_user(&mut self, new_user: NewUser) -> Result<User, RepositoryError<Self::BackendError>>;
|
||||
|
||||
async fn update_user(&mut self, user: User) -> Result<Option<User>, Self::BackendError>;
|
||||
async fn update_user(&mut self, user: User) -> Result<Option<User>, RepositoryError<Self::BackendError>>;
|
||||
|
||||
async fn remove_user(&mut self, id: i32) -> Result<Option<User>, Self::BackendError>;
|
||||
async fn remove_user(&mut self, id: i32) -> Result<Option<User>, RepositoryError<Self::BackendError>>;
|
||||
}
|
||||
|
||||
pub struct User {
|
||||
|
||||
Reference in New Issue
Block a user