Skip to main content

max / goingson

1.6 KB · 57 lines History Blame Raw
1 //! Backup settings types and DTOs.
2
3 use chrono::{DateTime, Utc};
4 use serde::{Deserialize, Serialize};
5 use uuid::Uuid;
6
7 // ============ Backup Settings ============
8
9 /// User's backup configuration.
10 #[derive(Debug, Clone, Serialize, Deserialize)]
11 #[serde(rename_all = "camelCase")]
12 pub struct BackupSettings {
13 /// Unique identifier.
14 pub id: Uuid,
15 /// Owner user ID.
16 pub user_id: Uuid,
17 /// Whether automatic backups are enabled.
18 pub auto_backup_enabled: bool,
19 /// Minutes between automatic backups.
20 pub backup_frequency_minutes: i32,
21 /// Maximum number of backups to retain.
22 pub max_backups_to_keep: i32,
23 /// When the last backup was created.
24 pub last_backup_at: Option<DateTime<Utc>>,
25 /// When settings were created.
26 pub created_at: DateTime<Utc>,
27 /// When settings were last modified.
28 pub updated_at: DateTime<Utc>,
29 }
30
31 impl Default for BackupSettings {
32 fn default() -> Self {
33 Self {
34 id: Uuid::new_v4(),
35 user_id: Uuid::nil(),
36 auto_backup_enabled: true,
37 backup_frequency_minutes: 15,
38 max_backups_to_keep: 1,
39 last_backup_at: None,
40 created_at: Utc::now(),
41 updated_at: Utc::now(),
42 }
43 }
44 }
45
46 /// Data for creating or updating backup settings.
47 #[derive(Debug, Clone, Serialize, Deserialize)]
48 #[serde(rename_all = "camelCase")]
49 pub struct NewBackupSettings {
50 /// Whether automatic backups are enabled.
51 pub auto_backup_enabled: bool,
52 /// Minutes between automatic backups.
53 pub backup_frequency_minutes: i32,
54 /// Maximum number of backups to retain.
55 pub max_backups_to_keep: i32,
56 }
57