steid

@jamesgill /

steid/src/domain/repository/user_repo.rs
908 BCode·Blame·Raw
fc5b566feat: repository ports and in-memory implementations1mo
1use super::RepositoryResult;
2use crate::domain::{Email, User, UserId};
3
4/// Persistence for [`User`].
5pub trait UserRepository: Send + Sync {
6 /// Looks a user up by id.
7 fn find_by_id(
8 &self,
9 id: &UserId,
10 ) -> impl Future<Output = RepositoryResult<Option<User>>> + Send;
11
12 /// Looks a user up by email — the credential used to sign in.
13 fn find_by_email(
14 &self,
15 email: &Email,
16 ) -> impl Future<Output = RepositoryResult<Option<User>>> + Send;
17
18 /// Inserts or replaces a user.
19 ///
20 /// The user's organisation must already exist: the foreign key runs that
21 /// direction, and saving in the other order fails.
22 fn save(&self, user: &User) -> impl Future<Output = RepositoryResult<()>> + Send;
23
24 /// Whether any user exists. Drives first-boot bootstrap.
25 fn any_exist(&self) -> impl Future<Output = RepositoryResult<bool>> + Send;
26}