| 1 |
use super::{Result, SyncAccountId, User, UserId, async_trait}; |
| 2 |
|
| 3 |
|
| 4 |
#[async_trait] |
| 5 |
pub trait UserRepository: Send + Sync { |
| 6 |
|
| 7 |
async fn create(&self, email: &str, password: &str, display_name: &str) -> Result<User>; |
| 8 |
|
| 9 |
|
| 10 |
async fn find_by_email(&self, email: &str) -> Result<Option<User>>; |
| 11 |
|
| 12 |
|
| 13 |
async fn authenticate(&self, email: &str, password: &str) -> Result<Option<User>>; |
| 14 |
|
| 15 |
|
| 16 |
async fn update_last_login(&self, user_id: UserId) -> Result<()>; |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
#[async_trait] |
| 21 |
pub trait SyncAccountRepository: Send + Sync { |
| 22 |
|
| 23 |
async fn list_all(&self, user_id: UserId) -> Result<Vec<crate::models::SyncAccount>>; |
| 24 |
|
| 25 |
|
| 26 |
async fn get_by_id( |
| 27 |
&self, |
| 28 |
id: SyncAccountId, |
| 29 |
user_id: UserId, |
| 30 |
) -> Result<Option<crate::models::SyncAccount>>; |
| 31 |
|
| 32 |
|
| 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 |
|
| 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 |
|
| 53 |
async fn delete(&self, id: SyncAccountId, user_id: UserId) -> Result<bool>; |
| 54 |
} |
| 55 |
|