Skip to main content

OdbBuilder

Struct OdbBuilder 

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

Configure and construct an Odb with a pluggable primary backend.

Implementations§

Source§

impl OdbBuilder

Source

pub fn files(objects_dir: impl AsRef<Path>) -> Self

Default files-backed layout rooted at objects_dir (the repository’s objects/ tree).

When passed to RepositoryBuilder::odb_builder, any spelling of the repository’s objects/ directory is accepted: a path through symlinks, or a relative path (resolved against the environment’s current directory). With a custom Self::primary the directory need not exist, but it must still name the repository’s objects/ directory.

Source

pub fn primary(self, store: Arc<dyn WritableObjectStore>) -> Self

Replace the default super::store::FilesSource primary with a custom store.

Writes and primary reads go through this backend, including commits, staging (crate::porcelain::add::stage), merges, stash, notes, and bundle creation. Repository::fsck validates the objects this store lists. Received packs are written into it object by object: ingest_received_pack and Bundle::unbundle resolve every delta and call WritableObjectStore::write instead of installing a pack under objects/pack/.

Remote::fetch, Remote::push, pull, bundles, and clone_into read and write objects through the custom primary. Partial-clone filters (operation: "partial fetch") and filesystem maintenance still refuse when they need on-disk pack layout:

History walks never read commit-graph files from objects/ for a custom primary: such a file describes the files layout, not this store. To give walks a commit-graph, build one with crate::maintenance::build_commit_graph, persist its bytes in the store, and attach it with Self::commit_graph when opening the repository.

The store’s ObjectStore::hash_algo must match the repository’s object format: RepositoryBuilder::open fails with Error::ObjectFormatMismatch otherwise. Self::build does not check, since it has no repository config to compare against.

Source

pub fn push_read_source(self, store: Arc<dyn ObjectStore>) -> Self

Append a read-only store consulted after the primary and before alternates.

Like Self::primary, its hash algorithm must match the repository’s object format or RepositoryBuilder::open fails with Error::ObjectFormatMismatch.

Source

pub fn commit_graph(self, chain: Arc<CommitGraphChain>) -> Self

Attach a commit-graph for history walks to consult, for any primary store.

Rev-list, merge-base, ancestry checks, rev-parse navigation, blame and path-limited log read parents, root trees, committer dates and generation numbers from chain, and test changed-path Bloom filters when it has them, instead of reading commit objects. Commits missing from the graph (written after it was built) are read from the store as usual, so a graph that covers only older history stays correct.

An attached graph replaces any graph file under objects/info/. It is trusted, not checked against the store: every commit it lists must be in this database with exactly the parents and tree it records, which holds for a graph crate::maintenance::build_commit_graph built from this repository. Build it with CommitGraphChain::from_bytes.

The graph’s CommitGraphChain::hash_algo must match the repository’s object format, or RepositoryBuilder::open fails with Error::ObjectFormatMismatch.

Source

pub fn alternates(self, enabled: bool) -> Self

When false, skip info/alternates, environment alternates, and submodule object dirs.

Source

pub fn objects_dir(&self) -> &Path

objects/ directory this builder targets.

Source

pub fn build(self) -> Odb

Construct an Odb handle (attach Odb::with_config_git_dir when opening a repository).

Trait Implementations§

Source§

impl Clone for OdbBuilder

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 OdbBuilder

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