diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-09-22 16:49:51 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-09-22 16:49:51 +0800 |
| commit | b0ae3b3b5c8b005b3f7cb2b26b17ae521a38c669 (patch) | |
| tree | ecb8883f1c53ea1602d50c8a57d59d8d3b2a177c /crates/env/src/workspace/vault/config.rs | |
| parent | 23f09dabe279233a960786d5048266de7f216c12 (diff) | |
Modify the file structure
Diffstat (limited to 'crates/env/src/workspace/vault/config.rs')
| -rw-r--r-- | crates/env/src/workspace/vault/config.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/env/src/workspace/vault/config.rs b/crates/env/src/workspace/vault/config.rs new file mode 100644 index 0000000..983a9e5 --- /dev/null +++ b/crates/env/src/workspace/vault/config.rs @@ -0,0 +1,37 @@ +use cfg_file::ConfigFile; +use serde::{Deserialize, Serialize}; + +use crate::constants::SERVER_FILE_VAULT; +use crate::workspace::member::Member; +use crate::workspace::vault::MemberId; + +#[derive(Default, Serialize, Deserialize, ConfigFile)] +#[cfg_file(path = SERVER_FILE_VAULT)] +pub struct VaultConfig { + /// Vault name, which can be used as the project name and generally serves as a hint + vault_name: String, + + /// Vault admin id, a list of member id representing administrator identities + vault_admin_list: Vec<MemberId>, +} + +impl VaultConfig { + // Change name of the vault. + pub fn change_name(&mut self, name: impl Into<String>) { + self.vault_name = name.into() + } + + // Add admin + pub fn add_admin(&mut self, member: &Member) { + let uuid = member.id(); + if !self.vault_admin_list.contains(&uuid) { + self.vault_admin_list.push(uuid); + } + } + + // Remove admin + pub fn remove_admin(&mut self, member: &Member) { + let id = member.id(); + self.vault_admin_list.retain(|x| x != &id); + } +} |
