Skip to main content

max / goingson

1.9 KB · 57 lines History Blame Raw
1 use super::{DateTime, NewSavedView, Result, SavedView, SavedViewId, UserId, Utc, async_trait};
2
3 /// Repository for saved view / filter configurations.
4 #[async_trait]
5 pub trait SavedViewRepository: Send + Sync {
6 /// Lists all saved views for a user.
7 async fn list_all(&self, user_id: UserId) -> Result<Vec<SavedView>>;
8
9 /// Lists pinned views for sidebar display.
10 async fn list_pinned(&self, user_id: UserId) -> Result<Vec<SavedView>>;
11
12 /// Gets a saved view by ID.
13 async fn get_by_id(&self, id: SavedViewId, user_id: UserId) -> Result<Option<SavedView>>;
14
15 /// Creates a new saved view.
16 async fn create(&self, user_id: UserId, view: NewSavedView) -> Result<SavedView>;
17
18 /// Updates an existing saved view.
19 async fn update(
20 &self,
21 id: SavedViewId,
22 user_id: UserId,
23 view: NewSavedView,
24 ) -> Result<Option<SavedView>>;
25
26 /// Deletes a saved view.
27 async fn delete(&self, id: SavedViewId, user_id: UserId) -> Result<bool>;
28
29 /// Toggles the pinned status of a view.
30 async fn toggle_pinned(&self, id: SavedViewId, user_id: UserId) -> Result<Option<SavedView>>;
31
32 /// Updates the position of a view in the sidebar.
33 async fn update_position(
34 &self,
35 id: SavedViewId,
36 user_id: UserId,
37 position: i32,
38 ) -> Result<Option<SavedView>>;
39 }
40
41 /// Repository for backup settings management.
42 #[async_trait]
43 pub trait BackupSettingsRepository: Send + Sync {
44 /// Gets the backup settings for a user.
45 async fn get(&self, user_id: UserId) -> Result<Option<crate::models::BackupSettings>>;
46
47 /// Creates or updates backup settings.
48 async fn upsert(
49 &self,
50 user_id: UserId,
51 settings: crate::models::NewBackupSettings,
52 ) -> Result<crate::models::BackupSettings>;
53
54 /// Updates the last backup timestamp.
55 async fn update_last_backup_at(&self, user_id: UserId, timestamp: DateTime<Utc>) -> Result<()>;
56 }
57