Skip to main content

VaultMap

Struct VaultMap 

Source
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

Source

pub fn load(data_dir: &Path) -> Self

Source

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.

Source

pub fn save(&self, data_dir: &Path) -> Result<()>

Source

pub fn record(&mut self, stable: &str, vault: &VaultV1, root: &Path)

Record a resolve answer for stable, remembering root.

Source

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).

Source

pub fn for_scope(self, connected: &str) -> Self

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.

Source

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.

Source

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.

Source

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.

Source

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 Clone for VaultMap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VaultMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VaultMap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for VaultMap

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for VaultMap

Source§

impl PartialEq for VaultMap

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for VaultMap

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for VaultMap

Auto Trait Implementations§

§

impl Forget for VaultMap

§

impl Freeze for VaultMap
where *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 VaultMap
where NodeRef<Owned, String, VaultRecord, LeafOrInternal>: Send, BoxRaw<(String, VaultRecord)>: Send, RawVecInner: Send,

§

impl Sync for VaultMap
where NodeRef<Owned, String, VaultRecord, LeafOrInternal>: Sync, BoxRaw<(String, VaultRecord)>: Sync, RawVecInner: Sync,

§

impl Unpin for VaultMap
where *const LeafNode<String, VaultRecord> is !null: Unpin, Box<(String, VaultRecord)>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for VaultMap

§

impl UnwindSafe for VaultMap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more