Skip to main content

Crate gix_odb

Crate gix_odb 

Source
Expand description

Git stores all of its data as Objects, which are data along with a hash over all data. Thus it’s an object store indexed by the signature of data itself with inherent deduplication: the same data will have the same hash, and thus occupy the same space within the store.

There is only one all-round object store, also known as the Store, as it supports everything most of what git has to offer.

  • loose object reading and writing
  • access to packed objects
  • multiple loose objects and pack locations as gathered from alternates files.

§Write And Read Loose Objects

use gix_object::{FindExt, Write};

let (_dir, odb) = doctest::empty_store()?;
let id = odb.write_buf(gix_object::Kind::Blob, b"hello")?;

let mut buf = Vec::new();
let object = odb.find(&id, &mut buf)?;
assert_eq!(object.kind, gix_object::Kind::Blob);
assert_eq!(object.data, b"hello");

§Inspect Headers Without Decoding The Object

use gix_object::Write;
use gix_odb::HeaderExt;

let (_dir, odb) = doctest::empty_store()?;
let id = odb.write_buf(gix_object::Kind::Blob, b"hello")?;

let header = odb.header(&id)?;
assert_eq!(header.kind(), gix_object::Kind::Blob);
assert_eq!(header.size(), 5);

§Feature Flags

  • sha1 — Enable support for the SHA-1 hash by enabling the respective feature in the gix-hash crate.
  • serde — Data structures implement serde::Serialize and serde::Deserialize.

Re-exports§

pub use gix_pack as pack;

Modules§

alternate
A file with directories of other git object databases to use when reading objects.
cache
find
loose
An object database storing each object in a zlib compressed file with its hash in the path
memory
store
The standard object store which should fit all needs.

Structs§

Cache
A way to access objects along with pre-configured thread-local caches for packed base objects as well as objects themselves.
Sink
It can optionally compress the content, similarly to what would happen when using a loose::Store.
Store
The object store for use in any applications with support for auto-updates in the light of changes to the object database.

Traits§

Header
A way to obtain object properties without fully decoding it.
HeaderExt
An extension trait with convenience functions.

Functions§

at
Create a new cached handle to the object store.
at_opts
Create a new cached handle to the object store with support for additional options.
sink
Create a new Sink with compression disabled.

Type Aliases§

Handle
A thread-local handle to access any object.
HandleArc
A thread-local handle to access any object, but thread-safe and independent of the actual type of OwnShared or feature toggles in gix-features.