Skip to main content

RepoCatalog

Struct RepoCatalog 

Source
pub struct RepoCatalog { /* private fields */ }
Expand description

Create, open, list and delete repositories.

Cheap to clone; every clone reads and writes the same document.

Implementations§

Source§

impl RepoCatalog

Source

pub fn new(store: Arc<dyn ControlStore>) -> Result<Self>

Open the catalog held in store (the certificate-identity plan).

This is the control store: the server’s own, not a repository’s.

Source

pub fn ref_name(&self) -> &str

The name the catalog is stored under.

Source

pub fn history(&self) -> Result<Vec<DocVersion>>

Every version this catalog has ever had, oldest first (the certificate-identity plan). See crate::AuthTable::history.

Source

pub fn create_namespace(&self, name: &str) -> Result<Namespace>

Create a namespace.

Nested names (team/sub) are allowed and every level is validated by the sandbox’s component rules, so a namespace can never be a path escape.

Source

pub fn set_namespace_explode_budget( &self, name: &str, bytes: Option<u64>, ) -> Result<Namespace>

Set (or clear) an account’s exploded-cache quota.

None puts the namespace back on the server’s default; Some(0) is unlimited and is a decision rather than an absence. The quota reaches a repository the next time its store is opened, and every store already open under this namespace immediately — see ServerStores::apply_explode_quota.

It cannot fail a read and it cannot lose an object: the cache it bounds is re-derivable from the packs, which it does not bound. Lowering a quota below what a repository already holds evicts; it never refuses.

Source

pub fn namespace_explode_budget(&self, name: &str) -> Result<Option<u64>>

This namespace’s quota, or None for “the server’s default”. A missing namespace is None too: a repository whose namespace row is gone is a broken catalog, and answering “the default” is the safe reading of it.

Source

pub fn set_namespace_public( &self, name: &str, public: bool, ) -> Result<Namespace>

Make a namespace public, or private again (Namespace::public).

Only the stored fact: who may change it (the account admin) is the gRPC layer’s question (Repos.SetNamespaceSettings). It touches no repository — a private repository stays private in a public namespace.

Source

pub fn set_namespace_events_public( &self, name: &str, public: bool, ) -> Result<Namespace>

Make an account’s emitted events public, or private again (Namespace::events_public). The stored fact only, as RepoCatalog::set_namespace_public.

Source

pub fn version(&self) -> Result<Option<BlobId>>

The catalog’s version: changes exactly when any namespace or repository row does. One pointer read — what lets a reader that keeps its own per-namespace index of the catalog (the server’s usage ledger) rebuild it only when something changed, instead of listing every repository on every read.

Source

pub fn namespaces(&self) -> Result<Vec<Namespace>>

Every namespace, by name. O(namespaces), the listing path.

Source

pub fn namespace(&self, name: &str) -> Result<Option<Namespace>>

One namespace, if it exists.

Source

pub fn delete_namespace( &self, name: &str, delete_repos: bool, ) -> Result<Vec<Repo>>

Delete a namespace, and return the repositories that went with it.

Refuses a namespace that still holds repositories unless delete_repos. Deleting a tenant’s repositories has to be asked for explicitly.

Source

pub fn create(&self, spec: NewRepo) -> Result<Repo>

Create a repository.

The namespace must already exist. A repository is never allowed to conjure one, because then a typo in a push URL would silently become a tenant.

Source

pub fn open(&self, path: &RepoRef) -> Result<Repo>

Look a repository up, failing if it is not there.

This is what the SSH layer calls after the sandbox has produced a RepoRef: a path that parses is not a repository that exists.

Source

pub fn get(&self, path: &RepoRef) -> Result<Option<Repo>>

Look a repository up.

This is the connection path. Control::resolve calls it for every SSH session. One shard probe, and no object read at all once the catalog has been read since it last changed.

Source

pub fn get_many(&self, paths: &[RepoRef]) -> Result<Vec<Option<Repo>>>

Many rows, one read of the catalog (round 5.3.1): get for each path, the document’s pointer read once rather than once per row — a listing’s access check asks about every row it lists.

Source

pub fn contains(&self, path: &RepoRef) -> Result<bool>

Is this repository in the catalog?

Source

pub fn list(&self, namespace: Option<&str>) -> Result<Vec<Repo>>

Every repository, or every repository in one namespace, ordered by key.

O(repositories) either way; see RepoCatalog::delete_namespace.

Source

pub fn delete(&self, path: &RepoRef) -> Result<Repo>

Remove a repository’s metadata and hand it back.

The caller owns the storage: whatever backend held its objects and refs is still there afterwards and must be dealt with separately.

Source

pub fn set_default_branch(&self, path: &RepoRef, branch: &str) -> Result<Repo>

Record another default branch for a repository.

This writes the catalog and nothing else. The repository’s own HEAD is a projection of this value and is moved by point_head_at, which whoever owns the repository’s stores calls with the Repo this hands back. Doing it here is not possible: the catalog holds metadata only and has never had a repository’s ref store (see this module’s opening comment).

Source

pub fn set_visibility( &self, path: &RepoRef, visibility: Visibility, ) -> Result<Repo>

Change a repository’s visibility.

Source

pub fn set_encrypted(&self, path: &RepoRef, encrypted: bool) -> Result<Repo>

Turn a repository’s “encrypted” flag on or off (Repos.SetEncrypted; the account admin’s decision, checked by the caller).

Source

pub fn counts(&self) -> Result<(usize, usize)>

How many namespaces and repositories there are, for Admin.Stats.

Trait Implementations§

Source§

impl Clone for RepoCatalog

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 RepoCatalog

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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