fc5b566feat: repository ports and in-memory implementations1mo | 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | pub mod membership_repo; |
| 8 | pub mod org_repo; |
c5b3ff5feat: repository persistence24d | 9 | pub mod repo_repo; |
54a0eaffeat: session storage and actor resolution1mo | 10 | pub mod session_repo; |
8608574feat: personal access tokens, as a domain type8d | 11 | pub mod token_repo; |
fc5b566feat: repository ports and in-memory implementations1mo | 12 | pub mod user_repo; |
| 13 | |
| 14 | pub use membership_repo::MembershipRepository; |
| 15 | pub use org_repo::OrgRepository; |
c5b3ff5feat: repository persistence24d | 16 | pub use repo_repo::RepoRepository; |
54a0eaffeat: session storage and actor resolution1mo | 17 | pub use session_repo::SessionRepository; |
8608574feat: personal access tokens, as a domain type8d | 18 | pub use token_repo::TokenRepository; |
fc5b566feat: repository ports and in-memory implementations1mo | 19 | pub use user_repo::UserRepository; |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | #[derive(Debug)] |
| 26 | pub enum RepositoryError { |
| 27 | Backend(Box<dyn std::error::Error + Send + Sync>), |
| 28 | } |
| 29 | |
| 30 | impl RepositoryError { |
| 31 | pub fn backend(error: impl Into<Box<dyn std::error::Error + Send + Sync>>) -> Self { |
| 32 | Self::Backend(error.into()) |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | impl std::fmt::Display for RepositoryError { |
| 37 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 38 | match self { |
| 39 | Self::Backend(error) => write!(f, "storage failure: {error}"), |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | impl std::error::Error for RepositoryError { |
| 45 | fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { |
| 46 | match self { |
| 47 | Self::Backend(error) => Some(&**error), |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | pub type RepositoryResult<T> = Result<T, RepositoryError>; |