767 BRaw
| 1 | use super::RepositoryResult; |
| 2 | use crate::domain::{Membership, OrgId, UserId}; |
| 3 | |
| 4 | /// Persistence for [`Membership`]. |
| 5 | pub trait MembershipRepository: Send + Sync { |
| 6 | /// Finds the membership linking a user to an organisation, if any. |
| 7 | /// |
| 8 | /// This is the authorization lookup: a `None` means no access to private content. |
| 9 | fn find( |
| 10 | &self, |
| 11 | org_id: &OrgId, |
| 12 | user_id: &UserId, |
| 13 | ) -> impl Future<Output = RepositoryResult<Option<Membership>>> + Send; |
| 14 | |
| 15 | /// Every organisation the user belongs to. |
| 16 | fn list_for_user( |
| 17 | &self, |
| 18 | user_id: &UserId, |
| 19 | ) -> impl Future<Output = RepositoryResult<Vec<Membership>>> + Send; |
| 20 | |
| 21 | fn save(&self, membership: &Membership) -> impl Future<Output = RepositoryResult<()>> + Send; |
| 22 | } |