diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-01-02 23:00:39 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-01-02 23:00:39 +0800 |
| commit | ba11b73da83d5f6c66129b52cff7a45d8994a6a0 (patch) | |
| tree | 9b81d605e8732cbe07e54858020c6c1bbfd84034 /crates/vcs_data/src/data | |
| parent | e982cd090efc8786f32818cfd26b2c07dd801930 (diff) | |
Rename vault admin to host and add serde renames
- Rename `vault_admin_list` to `vault_host_list` in config and actions
- Add `#[serde(rename)]` attributes to all data structures for shorter
JSON keys
- Update field renames in LocalConfig, LatestFileData, LatestInfo,
LocalSheetData, Member, SheetData, Share, and VirtualFileMeta
Diffstat (limited to 'crates/vcs_data/src/data')
| -rw-r--r-- | crates/vcs_data/src/data/local/config.rs | 5 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/local/latest_file_data.rs | 8 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/local/latest_info.rs | 11 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/local/local_sheet.rs | 7 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/member.rs | 2 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/sheet.rs | 6 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/vault/config.rs | 22 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/vault/sheet_share.rs | 4 | ||||
| -rw-r--r-- | crates/vcs_data/src/data/vault/virtual_file.rs | 6 |
9 files changed, 56 insertions, 15 deletions
diff --git a/crates/vcs_data/src/data/local/config.rs b/crates/vcs_data/src/data/local/config.rs index cfbc0d4..8a89c20 100644 --- a/crates/vcs_data/src/data/local/config.rs +++ b/crates/vcs_data/src/data/local/config.rs @@ -26,14 +26,17 @@ const SHEET_NAME: &str = "{sheet_name}"; 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. + #[serde(rename = "addr")] 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. + #[serde(rename = "as")] using_account: MemberId, /// Whether the current member is interacting as a host. /// In host mode, full Vault operation permissions are available except for adding new content. + #[serde(rename = "host")] using_host_mode: bool, /// Whether the local workspace is stained. @@ -42,9 +45,11 @@ pub struct LocalConfig { /// /// If the value is None, it means not stained; /// otherwise, it contains the stain identifier (i.e., the upstream vault's unique ID) + #[serde(rename = "up_uid")] stained_uuid: Option<VaultUuid>, /// The name of the sheet currently in use. + #[serde(rename = "use")] sheet_in_use: Option<SheetName>, } diff --git a/crates/vcs_data/src/data/local/latest_file_data.rs b/crates/vcs_data/src/data/local/latest_file_data.rs index 8a6a3cb..5248cfb 100644 --- a/crates/vcs_data/src/data/local/latest_file_data.rs +++ b/crates/vcs_data/src/data/local/latest_file_data.rs @@ -20,18 +20,24 @@ const ACCOUNT: &str = "{account}"; #[cfg_file(path = CLIENT_FILE_MEMBER_HELD_NOSET)] pub struct LatestFileData { /// File holding status + #[serde(rename = "held")] held_status: HashMap<VirtualFileId, HeldStatus>, /// File version + #[serde(rename = "ver")] versions: HashMap<VirtualFileId, VirtualFileVersion>, } #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub enum HeldStatus { + #[serde(rename = "Hold")] HeldWith(MemberId), // Held, status changes are sync to the client - NotHeld, // Not held, status changes are sync to the client + + #[serde(rename = "None")] + NotHeld, // Not held, status changes are sync to the client #[default] + #[serde(rename = "Unknown")] WantedToKnow, // Holding status is unknown, notify server must inform client } diff --git a/crates/vcs_data/src/data/local/latest_info.rs b/crates/vcs_data/src/data/local/latest_info.rs index a2456fc..e11836b 100644 --- a/crates/vcs_data/src/data/local/latest_info.rs +++ b/crates/vcs_data/src/data/local/latest_info.rs @@ -30,31 +30,39 @@ pub struct LatestInfo { // Sheets /// Visible sheets, /// indicating which sheets I can edit + #[serde(rename = "my")] pub visible_sheets: Vec<SheetName>, /// Invisible sheets, /// indicating which sheets I can export files to (these sheets are not readable to me) + #[serde(rename = "others")] pub invisible_sheets: Vec<SheetInfo>, /// Reference sheets, /// indicating sheets owned by the host, visible to everyone, /// but only the host can modify or add mappings within them + #[serde(rename = "refsheets")] pub reference_sheets: HashSet<SheetName>, /// Reference sheet data, indicating what files I can get from the reference sheet + #[serde(rename = "ref")] pub ref_sheet_content: SheetData, /// Reverse mapping from virtual file IDs to actual paths in reference sheets + #[serde(rename = "ref_vfs")] pub ref_sheet_vfs_mapping: HashMap<VirtualFileId, SheetPathBuf>, /// Shares in my sheets, indicating which external merge requests have entries that I can view + #[serde(rename = "shares")] pub shares_in_my_sheets: HashMap<SheetName, HashMap<SheetShareId, Share>>, /// Update instant + #[serde(rename = "update")] pub update_instant: Option<SystemTime>, // Members /// All member information of the vault, allowing me to contact them more conveniently + #[serde(rename = "members")] pub vault_members: Vec<Member>, } @@ -67,6 +75,9 @@ impl LatestInfo { #[derive(Default, Serialize, Deserialize)] pub struct SheetInfo { + #[serde(rename = "name")] pub sheet_name: SheetName, + + #[serde(rename = "holder")] pub holder_name: Option<MemberId>, } diff --git a/crates/vcs_data/src/data/local/local_sheet.rs b/crates/vcs_data/src/data/local/local_sheet.rs index 4ebdaac..8ad059f 100644 --- a/crates/vcs_data/src/data/local/local_sheet.rs +++ b/crates/vcs_data/src/data/local/local_sheet.rs @@ -32,16 +32,17 @@ pub struct LocalSheet<'a> { #[cfg_file(path = CLIENT_FILE_LOCAL_SHEET_NOSET)] // Do not use LocalSheet::write or LocalSheet::read pub struct LocalSheetData { /// Local file path to metadata mapping. - #[serde(rename = "mapping")] + #[serde(rename = "map")] pub(crate) mapping: HashMap<LocalFilePathBuf, LocalMappingMetadata>, + #[serde(rename = "vfs")] pub(crate) vfs: HashMap<VirtualFileId, LocalFilePathBuf>, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct LocalMappingMetadata { /// Hash value generated immediately after the file is downloaded to the local workspace - #[serde(rename = "hash")] + #[serde(rename = "base_hash")] pub(crate) hash_when_updated: String, /// Time when the file was downloaded to the local workspace @@ -57,7 +58,7 @@ pub struct LocalMappingMetadata { pub(crate) version_desc_when_updated: VirtualFileVersionDescription, /// Version when the file was downloaded to the local workspace - #[serde(rename = "version")] + #[serde(rename = "ver")] pub(crate) version_when_updated: VirtualFileVersion, /// Virtual file ID corresponding to the local path diff --git a/crates/vcs_data/src/data/member.rs b/crates/vcs_data/src/data/member.rs index b5136a1..7e99488 100644 --- a/crates/vcs_data/src/data/member.rs +++ b/crates/vcs_data/src/data/member.rs @@ -9,9 +9,11 @@ pub type MemberId = String; #[derive(Debug, Eq, Clone, ConfigFile, Serialize, Deserialize)] pub struct Member { /// Member ID, the unique identifier of the member + #[serde(rename = "id")] id: String, /// Member metadata + #[serde(rename = "meta")] metadata: HashMap<String, String>, } diff --git a/crates/vcs_data/src/data/sheet.rs b/crates/vcs_data/src/data/sheet.rs index 0a52e26..64b1985 100644 --- a/crates/vcs_data/src/data/sheet.rs +++ b/crates/vcs_data/src/data/sheet.rs @@ -33,21 +33,27 @@ pub struct Sheet<'a> { #[derive(Default, Serialize, Deserialize, ConfigFile, Clone)] pub struct SheetData { /// The write count of the current sheet + #[serde(rename = "v")] pub(crate) write_count: i32, /// The holder of the current sheet, who has full operation rights to the sheet mapping + #[serde(rename = "holder")] pub(crate) holder: Option<MemberId>, /// Mapping of sheet paths to virtual file IDs + #[serde(rename = "map")] pub(crate) mapping: HashMap<SheetPathBuf, SheetMappingMetadata>, /// Mapping of virtual file Ids to sheet paths + #[serde(rename = "id_map")] pub(crate) id_mapping: Option<HashMap<VirtualFileId, SheetPathBuf>>, } #[derive(Debug, Default, Serialize, Deserialize, ConfigFile, Clone, Eq, PartialEq)] pub struct SheetMappingMetadata { + #[serde(rename = "id")] pub id: VirtualFileId, + #[serde(rename = "ver")] pub version: VirtualFileVersion, } diff --git a/crates/vcs_data/src/data/vault/config.rs b/crates/vcs_data/src/data/vault/config.rs index 60f6cbb..caa8552 100644 --- a/crates/vcs_data/src/data/vault/config.rs +++ b/crates/vcs_data/src/data/vault/config.rs @@ -81,9 +81,9 @@ pub struct VaultConfig { #[serde(rename = "name")] vault_name: VaultName, - /// Vault admin id, a list of member id representing administrator identities - #[serde(rename = "admin")] - vault_admin_list: Vec<MemberId>, + /// Vault host ids, a list of member id representing administrator identities + #[serde(rename = "hosts")] + vault_host_list: Vec<MemberId>, /// Vault server configuration, which will be loaded when connecting to the server #[serde(rename = "profile")] @@ -125,7 +125,7 @@ impl Default for VaultConfig { Self { vault_uuid: Uuid::new_v4(), vault_name: "JustEnoughVault".to_string(), - vault_admin_list: Vec::new(), + vault_host_list: Vec::new(), server_config: VaultServerConfig { local_bind: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port: PORT, @@ -148,15 +148,15 @@ impl VaultConfig { /// 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); + if !self.vault_host_list.contains(&uuid) { + self.vault_host_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); + self.vault_host_list.retain(|x| x != &id); } /// Get vault UUID @@ -180,13 +180,13 @@ impl VaultConfig { } /// Get vault admin list - pub fn vault_admin_list(&self) -> &Vec<MemberId> { - &self.vault_admin_list + pub fn vault_host_list(&self) -> &Vec<MemberId> { + &self.vault_host_list } /// Set vault admin list - pub fn set_vault_admin_list(&mut self, vault_admin_list: Vec<MemberId>) { - self.vault_admin_list = vault_admin_list; + pub fn set_vault_host_list(&mut self, vault_host_list: Vec<MemberId>) { + self.vault_host_list = vault_host_list; } /// Get server config diff --git a/crates/vcs_data/src/data/vault/sheet_share.rs b/crates/vcs_data/src/data/vault/sheet_share.rs index b62c74b..af1aa53 100644 --- a/crates/vcs_data/src/data/vault/sheet_share.rs +++ b/crates/vcs_data/src/data/vault/sheet_share.rs @@ -23,9 +23,11 @@ const SHARE_ID: &str = "{share_id}"; #[derive(Default, Serialize, Deserialize, ConfigFile, Clone, Debug)] pub struct Share { /// Sharer: the member who created this share item + #[serde(rename = "sharer")] pub sharer: MemberId, /// Description of the share item + #[serde(rename = "desc")] pub description: String, /// Metadata path @@ -33,9 +35,11 @@ pub struct Share { pub path: Option<PathBuf>, /// From: which sheet the member exported the file from + #[serde(rename = "from")] pub from_sheet: SheetName, /// Mappings: the sheet mappings contained in the share item + #[serde(rename = "map")] pub mappings: HashMap<SheetPathBuf, SheetMappingMetadata>, } diff --git a/crates/vcs_data/src/data/vault/virtual_file.rs b/crates/vcs_data/src/data/vault/virtual_file.rs index 150a469..8dbcb5d 100644 --- a/crates/vcs_data/src/data/vault/virtual_file.rs +++ b/crates/vcs_data/src/data/vault/virtual_file.rs @@ -39,24 +39,30 @@ pub struct VirtualFile<'a> { #[derive(Default, Clone, Serialize, Deserialize, ConfigFile)] pub struct VirtualFileMeta { /// Current version of the virtual file + #[serde(rename = "ver")] current_version: VirtualFileVersion, /// The member who holds the edit right of the file + #[serde(rename = "holder")] hold_member: MemberId, /// Description of each version + #[serde(rename = "descs")] version_description: HashMap<VirtualFileVersion, VirtualFileVersionDescription>, /// Histories + #[serde(rename = "histories")] histories: Vec<VirtualFileVersion>, } #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct VirtualFileVersionDescription { /// The member who created this version + #[serde(rename = "creator")] pub creator: MemberId, /// The description of this version + #[serde(rename = "desc")] pub description: String, } |
