diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-13 14:27:59 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-13 14:27:59 +0800 |
| commit | b9bbfb31bee88f6b10a9cc5b49e7618bef9d0be5 (patch) | |
| tree | ef02095c73635b5ace574c26dfcb999017e34897 /crates/vcs_data/src/data/local/config.rs | |
| parent | c1d862d6df58173c24604e4dda33db8ce3be3ad7 (diff) | |
| parent | 4810f56e6a49b60923eb850d5944457650c81c75 (diff) | |
Merge pull request #21 from JustEnoughVCS/jvcs_dev
Jvcs dev
Diffstat (limited to 'crates/vcs_data/src/data/local/config.rs')
| -rw-r--r-- | crates/vcs_data/src/data/local/config.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/vcs_data/src/data/local/config.rs b/crates/vcs_data/src/data/local/config.rs index 5444047..338d01b 100644 --- a/crates/vcs_data/src/data/local/config.rs +++ b/crates/vcs_data/src/data/local/config.rs @@ -5,6 +5,7 @@ use std::net::SocketAddr; use crate::constants::CLIENT_FILE_WORKSPACE; use crate::constants::PORT; use crate::data::member::MemberId; +use crate::data::vault::config::VaultUuid; #[derive(Serialize, Deserialize, ConfigFile)] #[cfg_file(path = CLIENT_FILE_WORKSPACE)] @@ -16,6 +17,14 @@ pub struct LocalConfig { /// The member ID used by the current local workspace. /// This ID will be used to verify access permissions when connecting to the upstream server. using_account: MemberId, + + /// Whether the local workspace is stained. + /// + /// If stained, it can only set an upstream server with the same identifier. + /// + /// If the value is None, it means not stained; + /// otherwise, it contains the stain identifier (i.e., the upstream vault's unique ID) + stained_uuid: Option<VaultUuid>, } impl Default for LocalConfig { @@ -26,6 +35,7 @@ impl Default for LocalConfig { PORT, )), using_account: "unknown".to_string(), + stained_uuid: None, } } } @@ -50,4 +60,19 @@ impl LocalConfig { pub fn current_account(&self) -> MemberId { self.using_account.clone() } + + /// Check if the local workspace is stained. + pub fn stained(&self) -> bool { + self.stained_uuid.is_some() + } + + /// Stain the local workspace with the given UUID. + pub fn stain(&mut self, uuid: VaultUuid) { + self.stained_uuid = Some(uuid); + } + + /// Unstain the local workspace. + pub fn unstain(&mut self) { + self.stained_uuid = None; + } } |
