pub struct VaultMap {
pub vaults: BTreeMap<String, VaultRecord>,
pub origin: Option<String>,
}Expand description
<data_dir>/cloud/projects.json: stable identity → resolved vault.
A vault id is only valid on the Cloud and for the account (org) that
resolved it (rc3-81; rc4-2/rc4-6 for an account switch on the same
Cloud): the active records (projects) belong to the scope in origin
(vault_scope: <origin>#org=<org_id>). A connect to another Cloud
or account drops them (3.12.8 account scope: the enrollment removes the
local Cloud data of another server or team, and VaultMap::use_scope
applies the same rule to a map that is still there), so a connect
elsewhere never shows or syncs them; a connect back resolves anew.
Who sets origin:
- enrollment switches the map to the new Cloud and account
(
VaultMap::use_scope); - every write while connected stamps the map with the connected Cloud
and account and refuses a map of another one (
VaultMap::claim); - a disconnect that keeps the local data stamps the map with the Cloud and account it leaves, before their record is forgotten.
Readers that know the connected Cloud and account use
VaultMap::for_scope, which shows no records of another one (fail
closed).
A stamp without an account (only dev builds of rc3-81 wrote one) matches
no account (fail closed) until an enrollment resolves it to the account
the machine was enrolled with on that Cloud (VaultMap::use_scope).
Downgrade: an older engine reads the file but drops origin when it
saves it. The file is then unstamped again (the legacy rule of
VaultMap::use_scope applies) until the next write of a newer engine
stamps it with the connected scope. The parked records that rc3-81
builds wrote are ignored when read and dropped at the next save.
Fields§
§vaults: BTreeMap<String, VaultRecord>On disk as projects (pre-VA name) for downgrades and mixed-version teams.
origin: Option<String>The scope (Cloud and account, vault_scope) vaults was resolved
in; the Cloud origin alone in a file stamped before accounts were
recorded; None in a file written before origins were recorded (see
VaultMap::use_scope).
Implementations§
Source§impl VaultMap
impl VaultMap
pub fn load(data_dir: &Path) -> VaultMap
Sourcepub fn for_root(&self, root: &str) -> Option<&VaultRecord>
pub fn for_root(&self, root: &str) -> Option<&VaultRecord>
The vault of the local checkout root: the one recorded for it, else
(a linked git worktree never synced itself) the one of its main
checkout, which is the same repository.
pub fn save(&self, data_dir: &Path) -> Result<(), Error>
Sourcepub fn record(&mut self, stable: &str, vault: &VaultV1, root: &Path)
pub fn record(&mut self, stable: &str, vault: &VaultV1, root: &Path)
Record a resolve answer for stable, remembering root.
Sourcepub fn claim(&mut self, scope: &str) -> bool
pub fn claim(&mut self, scope: &str) -> bool
Stamp the map with scope (vault_scope), the Cloud and account
this machine is connected to while it writes: an unstamped map gets
it. false when the map belongs to another Cloud or account: the
caller records nothing (enrollment is the one switch).
Sourcepub fn for_scope(self, connected: &str) -> VaultMap
pub fn for_scope(self, connected: &str) -> VaultMap
This map as the Cloud and account at connected (vault_scope)
see it: without any records when they were resolved on another Cloud
or for another account (fail closed). A view for reading; never saved.
Sourcepub fn claim_enrolled(&mut self, scope: &str) -> bool
pub fn claim_enrolled(&mut self, scope: &str) -> bool
Self::claim for the scope this machine was enrolled with until
now (at a disconnect): a stamp with that Cloud alone (dev builds of
rc3-81) was written for this account and gets it added.
Sourcepub fn belongs_to(&self, scope: &str) -> bool
pub fn belongs_to(&self, scope: &str) -> bool
Whether the active records may be used in scope (vault_scope):
the map is unstamped (written before scopes were recorded; every
enrollment stamps it, so it belongs to the scope this machine is
still connected to) or stamped with exactly that Cloud and account.
Sourcepub fn use_scope(&mut self, scope: &str, legacy_scope: &str) -> bool
pub fn use_scope(&mut self, scope: &str, legacy_scope: &str) -> bool
Make the map belong to the Cloud and account at scope
(vault_scope): the active records of another scope are dropped
(3.12.8 account scope; nothing is kept for a connect back). A file
without an origin (written before origins were recorded) counts as
resolved on legacy_scope, its account included (fail closed:
another account on the same Cloud is another scope). A file stamped
with a Cloud alone (only dev builds of rc3-81 wrote one) counts as
resolved for the account of legacy_scope when that names the same
Cloud, else as a scope of its own that no account matches. Returns
whether anything changed.
Sourcepub fn forget_root(&mut self, root: &str) -> Option<VaultRecord>
pub fn forget_root(&mut self, root: &str) -> Option<VaultRecord>
Forget the local checkout root: it leaves the record that lists it
(a record without roots left is dropped). Returns that record, as it
was before.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for VaultMap
impl<'de> Deserialize<'de> for VaultMap
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<VaultMap, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<VaultMap, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for VaultMap
Source§impl Serialize for VaultMap
impl Serialize for VaultMap
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for VaultMap
Auto Trait Implementations§
impl Forget for VaultMap
impl Freeze for VaultMapwhere
*const LeafNode<String, VaultRecord> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, VaultRecord)>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl Move for VaultMap
impl RefUnwindSafe for VaultMap
impl Send for VaultMapwhere
NodeRef<Owned, String, VaultRecord, LeafOrInternal>: Send,
BoxRaw<(String, VaultRecord)>: Send,
RawVecInner: Send,
impl Sync for VaultMapwhere
NodeRef<Owned, String, VaultRecord, LeafOrInternal>: Sync,
BoxRaw<(String, VaultRecord)>: Sync,
RawVecInner: Sync,
impl Unpin for VaultMap
impl UnsafeUnpin for VaultMapwhere
*const LeafNode<String, VaultRecord> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, VaultRecord)>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe for VaultMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more