Skip to main content

max / goingson

1.5 KB · 37 lines History Blame Raw
1 use super::*;
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(&self, id: SyncAccountId, user_id: UserId) -> Result<Option<crate::models::SyncAccount>>;
27
28 /// Creates a new sync account.
29 async fn create(&self, user_id: UserId, provider: &str, account_name: &str, email: Option<&str>) -> Result<crate::models::SyncAccount>;
30
31 /// Updates a sync account.
32 async fn update(&self, id: SyncAccountId, user_id: UserId, account_name: &str, sync_calendars: bool, sync_contacts: bool, enabled: bool) -> Result<Option<crate::models::SyncAccount>>;
33
34 /// Deletes a sync account.
35 async fn delete(&self, id: SyncAccountId, user_id: UserId) -> Result<bool>;
36 }
37