summaryrefslogtreecommitdiff
path: root/crates/vcs_data/src/data/local
diff options
context:
space:
mode:
Diffstat (limited to 'crates/vcs_data/src/data/local')
-rw-r--r--crates/vcs_data/src/data/local/config.rs25
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;
+ }
}