diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-06 04:11:34 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-10-06 04:11:34 +0800 |
| commit | 87c3ec3fdcbd2294c3b9258d28ff47959e6eff68 (patch) | |
| tree | a601cb7e7d97917e4a79ae6db3698c8ecd31717c /crates/vcs_data/src/data/local/config.rs | |
| parent | ce4545a21d435d63827fb972406e749354ac687a (diff) | |
Move vcs crate to vcs_data for better separation of concerns
- Rename vcs crate to vcs_data to clearly define data layer
- Maintain all existing data structures and functionality
- Update dependencies to include action_system integration
- Preserve test structure in vcs_data_test directory
Diffstat (limited to 'crates/vcs_data/src/data/local/config.rs')
| -rw-r--r-- | crates/vcs_data/src/data/local/config.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/crates/vcs_data/src/data/local/config.rs b/crates/vcs_data/src/data/local/config.rs new file mode 100644 index 0000000..5444047 --- /dev/null +++ b/crates/vcs_data/src/data/local/config.rs @@ -0,0 +1,53 @@ +use cfg_file::ConfigFile; +use serde::{Deserialize, Serialize}; +use std::net::SocketAddr; + +use crate::constants::CLIENT_FILE_WORKSPACE; +use crate::constants::PORT; +use crate::data::member::MemberId; + +#[derive(Serialize, Deserialize, ConfigFile)] +#[cfg_file(path = CLIENT_FILE_WORKSPACE)] +pub struct LocalConfig { + /// The upstream address, representing the upstream address of the local workspace, + /// to facilitate timely retrieval of new updates from the upstream source. + upstream_addr: SocketAddr, + + /// 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, +} + +impl Default for LocalConfig { + fn default() -> Self { + Self { + upstream_addr: SocketAddr::V4(std::net::SocketAddrV4::new( + std::net::Ipv4Addr::new(127, 0, 0, 1), + PORT, + )), + using_account: "unknown".to_string(), + } + } +} + +impl LocalConfig { + /// Set the vault address. + pub fn set_vault_addr(&mut self, addr: SocketAddr) { + self.upstream_addr = addr; + } + + /// Get the vault address. + pub fn vault_addr(&self) -> SocketAddr { + self.upstream_addr + } + + /// Set the currently used account + pub fn set_current_account(&mut self, account: MemberId) { + self.using_account = account; + } + + /// Get the currently used account + pub fn current_account(&self) -> MemberId { + self.using_account.clone() + } +} |
