zoe_app_primitives/group/events/
settings.rs

1use serde::{Deserialize, Serialize};
2
3use super::permissions::GroupPermissions;
4
5/// Group settings and configuration for encrypted groups
6///
7/// These settings control various aspects of group behavior and permissions.
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
9pub struct GroupSettings {
10    /// Required permissions for various actions
11    pub permissions: GroupPermissions,
12    /// Group encryption and security settings
13    pub encryption_settings: EncryptionSettings,
14}
15
16/// Encryption-related settings for a group
17///
18/// Controls various encryption and security features for the group.
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
20pub struct EncryptionSettings {
21    /// Whether to rotate keys periodically (future feature)
22    ///
23    /// When enabled, the group will periodically rotate its encryption keys
24    /// to provide forward secrecy.
25    pub key_rotation_enabled: bool,
26
27    /// Key rotation interval in seconds (if enabled)
28    ///
29    /// How often to rotate keys when key rotation is enabled.
30    pub key_rotation_interval: Option<u64>,
31}
32
33impl GroupSettings {
34    /// Create new group settings with default permissions
35    pub fn new() -> Self {
36        Self::default()
37    }
38
39    /// Set group permissions
40    pub fn permissions(mut self, permissions: GroupPermissions) -> Self {
41        self.permissions = permissions;
42        self
43    }
44
45    /// Set encryption settings
46    pub fn encryption_settings(mut self, settings: EncryptionSettings) -> Self {
47        self.encryption_settings = settings;
48        self
49    }
50}
51
52impl EncryptionSettings {
53    /// Create new encryption settings
54    pub fn new() -> Self {
55        Self::default()
56    }
57
58    /// Enable key rotation with specified interval
59    pub fn with_key_rotation(mut self, interval_seconds: u64) -> Self {
60        self.key_rotation_enabled = true;
61        self.key_rotation_interval = Some(interval_seconds);
62        self
63    }
64}