summaryrefslogtreecommitdiff
path: root/crates/env/src/workspace/local/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/env/src/workspace/local/config.rs')
-rw-r--r--crates/env/src/workspace/local/config.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/env/src/workspace/local/config.rs b/crates/env/src/workspace/local/config.rs
new file mode 100644
index 0000000..ddb7dd0
--- /dev/null
+++ b/crates/env/src/workspace/local/config.rs
@@ -0,0 +1,37 @@
+use cfg_file::ConfigFile;
+use serde::{Deserialize, Serialize};
+use std::net::SocketAddr;
+
+use crate::constants::CLIENT_FILE_WORKSPACE;
+use crate::constants::PORT;
+
+#[derive(Serialize, Deserialize, ConfigFile)]
+#[cfg_file(path = CLIENT_FILE_WORKSPACE)]
+pub struct LocalConfig {
+ /// The vault address, representing the upstream address of the local workspace,
+ /// to facilitate timely retrieval of new updates from the upstream source.
+ vault_addr: SocketAddr,
+}
+
+impl Default for LocalConfig {
+ fn default() -> Self {
+ Self {
+ vault_addr: SocketAddr::V4(std::net::SocketAddrV4::new(
+ std::net::Ipv4Addr::new(127, 0, 0, 1),
+ PORT,
+ )),
+ }
+ }
+}
+
+impl LocalConfig {
+ /// Set the vault address.
+ pub fn set_vault_addr(&mut self, addr: SocketAddr) {
+ self.vault_addr = addr;
+ }
+
+ /// Get the vault address.
+ pub fn vault_addr(&self) -> SocketAddr {
+ self.vault_addr
+ }
+}