Add profile sync policy controls

This commit is contained in:
2026-05-08 03:44:36 -04:00
parent 38a847c27e
commit ada0a82da8
6 changed files with 139 additions and 10 deletions
+44
View File
@@ -6,6 +6,39 @@ pub enum ProfileKind {
Private,
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum ProfileSyncPolicy {
#[default]
Enabled,
Paused,
}
impl ProfileSyncPolicy {
#[must_use]
pub fn label(self) -> &'static str {
match self {
Self::Enabled => "Sync on",
Self::Paused => "Sync paused",
}
}
#[must_use]
pub fn action_label(self) -> &'static str {
match self {
Self::Enabled => "Pause Sync",
Self::Paused => "Resume Sync",
}
}
#[must_use]
pub fn toggled(self) -> Self {
match self {
Self::Enabled => Self::Paused,
Self::Paused => Self::Enabled,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Profile {
id: ProfileId,
@@ -13,6 +46,7 @@ pub struct Profile {
color_hex: u32,
kind: ProfileKind,
download_policy: DownloadPolicy,
sync_policy: ProfileSyncPolicy,
}
impl Profile {
@@ -24,6 +58,7 @@ impl Profile {
color_hex,
kind,
download_policy: DownloadPolicy::ask_every_time(),
sync_policy: ProfileSyncPolicy::default(),
}
}
@@ -52,7 +87,16 @@ impl Profile {
&self.download_policy
}
#[must_use]
pub fn sync_policy(&self) -> ProfileSyncPolicy {
self.sync_policy
}
pub fn set_download_policy(&mut self, download_policy: DownloadPolicy) {
self.download_policy = download_policy;
}
pub fn set_sync_policy(&mut self, sync_policy: ProfileSyncPolicy) {
self.sync_policy = sync_policy;
}
}