Skip to main content

zamsync_core/
access.rs

1/// Controls which events a serving node sends to connecting peers.
2///
3/// `All` (default): every peer receives all events it is missing -- suitable
4/// for hub-to-hub replication or fully trusted deployments.
5///
6/// `OwnOnly`: a peer P only receives events whose `origin_node == P`. This is
7/// the "hub in clinic mode": clinic A can upload its records to the hub and
8/// retrieve them back, but cannot read records from clinic B.
9#[derive(Debug, Clone, Default)]
10pub enum AccessPolicy {
11    #[default]
12    All,
13    OwnOnly,
14}
15
16impl std::str::FromStr for AccessPolicy {
17    type Err = String;
18
19    fn from_str(s: &str) -> Result<Self, Self::Err> {
20        match s {
21            "all" => Ok(Self::All),
22            "own" => Ok(Self::OwnOnly),
23            other => Err(format!("unknown policy '{other}': use 'all' or 'own'")),
24        }
25    }
26}