summaryrefslogtreecommitdiff
path: root/crates/vcs_data/src/data/local/member_held.rs
blob: 37bc18e611c74b7cc32b7bb9169e9f94a8203478 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::collections::HashMap;

use cfg_file::ConfigFile;
use serde::{Deserialize, Serialize};

use crate::{
    constants::CLIENT_FILE_MEMBER_HELD_NOSET,
    data::{member::MemberId, vault::virtual_file::VirtualFileId},
};

/// # Member Held Information
/// Records the files held by the member, used for permission validation
#[derive(Debug, Default, Clone, Serialize, Deserialize, ConfigFile)]
#[cfg_file(path = CLIENT_FILE_MEMBER_HELD_NOSET)]
pub struct MemberHeld {
    /// File holding status
    held_status: HashMap<VirtualFileId, HeldStatus>,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub enum HeldStatus {
    HeldWith(MemberId), // Held, status changes are sync to the client
    NotHeld,            // Not held, status changes are sync to the client

    #[default]
    WantedToKnow, // Holding status is unknown, notify server must inform client
}