Skip to main content

max / goingson

1.7 KB · 55 lines History Blame Raw
1 use super::{Result, SyncAccountId, User, UserId, async_trait};
2
3 /// Repository for user account operations.
4 #[async_trait]
5 pub trait UserRepository: Send + Sync {
6 /// Creates a new user account with hashed password.
7 async fn create(&self, email: &str, password: &str, display_name: &str) -> Result<User>;
8
9 /// Finds a user by email address.
10 async fn find_by_email(&self, email: &str) -> Result<Option<User>>;
11
12 /// Authenticates a user, returning the user if credentials are valid.
13 async fn authenticate(&self, email: &str, password: &str) -> Result<Option<User>>;
14
15 /// Updates the user's last login timestamp.
16 async fn update_last_login(&self, user_id: UserId) -> Result<()>;
17 }
18
19 /// Repository for sync account CRUD operations.
20 #[async_trait]
21 pub trait SyncAccountRepository: Send + Sync {
22 /// Lists all sync accounts for a user.
23 async fn list_all(&self, user_id: UserId) -> Result<Vec<crate::models::SyncAccount>>;
24
25 /// Retrieves a sync account by ID.
26 async fn get_by_id(
27 &self,
28 id: SyncAccountId,
29 user_id: UserId,
30 ) -> Result<Option<crate::models::SyncAccount>>;
31
32 /// Creates a new sync account.
33 async fn create(
34 &self,
35 user_id: UserId,
36 provider: &str,
37 account_name: &str,
38 email: Option<&str>,
39 ) -> Result<crate::models::SyncAccount>;
40
41 /// Updates a sync account.
42 async fn update(
43 &self,
44 id: SyncAccountId,
45 user_id: UserId,
46 account_name: &str,
47 sync_calendars: bool,
48 sync_contacts: bool,
49 enabled: bool,
50 ) -> Result<Option<crate::models::SyncAccount>>;
51
52 /// Deletes a sync account.
53 async fn delete(&self, id: SyncAccountId, user_id: UserId) -> Result<bool>;
54 }
55