GitStorage

Struct GitStorage 

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

Git storage backed by hashtree with LMDB persistence

Implementations§

Source§

impl GitStorage

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open or create a git storage at the given path

Source

pub fn has_object(&self, oid: &ObjectId) -> Result<bool>

Check if an object exists

Source

pub fn read_object(&self, oid: &ObjectId) -> Result<GitObject>

Read an object by ID

Source

pub fn write_object(&self, obj: &GitObject) -> Result<ObjectId>

Write an object, returning its ID

Source

pub fn write_blob(&self, content: &[u8]) -> Result<ObjectId>

Write a blob, returning its ID

Source

pub fn write_tree(&self, content: &[u8]) -> Result<ObjectId>

Write a tree, returning its ID

Source

pub fn write_commit(&self, content: &[u8]) -> Result<ObjectId>

Write a commit, returning its ID

Source

pub fn write_tag(&self, content: &[u8]) -> Result<ObjectId>

Write a tag, returning its ID

Source

pub fn write_raw_object( &self, obj_type: ObjectType, content: &[u8], ) -> Result<ObjectId>

Write raw object data (type + content already parsed)

Source

pub fn list_objects(&self) -> Result<Vec<ObjectId>>

List all object IDs

Source

pub fn read_ref(&self, name: &str) -> Result<Ref>

Read a ref

Source

pub fn write_ref(&self, name: &str, target: &Ref) -> Result<()>

Write a ref

Source

pub fn delete_ref(&self, name: &str) -> Result<bool>

Delete a ref

Source

pub fn resolve_ref(&self, name: &str) -> Result<ObjectId>

Resolve a ref to its final object ID (follows symbolic refs)

Source

pub fn list_refs(&self) -> Result<Vec<NamedRef>>

List all refs

Source

pub fn list_refs_with_prefix(&self, prefix: &str) -> Result<Vec<NamedRef>>

List refs matching a prefix (e.g., “refs/heads/”)

Source

pub fn compare_and_swap_ref( &self, name: &str, expected: Option<&ObjectId>, new_value: Option<&ObjectId>, ) -> Result<bool>

Update a ref atomically, checking the old value

Source

pub fn build_tree(&mut self) -> Result<[u8; 32]>

Build the merkle tree and return root hash (SHA-256) Includes .git/ directory and working tree from HEAD Also persists all nodes to LMDB

Source

pub fn get_root_hash(&mut self) -> Result<String>

Get root hash as hex string

Source

pub fn store(&self) -> &Arc<LmdbBlobStore>

Get the underlying store

Source

pub fn determine_default_branch(&self) -> Option<String>

Determine the default branch for HEAD Priority: master > main > alphabetically first branch

Source

pub fn extract_working_tree( &self, commit_oid: &ObjectId, ) -> Result<Vec<WorkingTreeEntry>>

Extract the working tree from a commit Returns a list of (path, mode, content) for all files

Source

pub fn load_from_root(&mut self, root_hash: &str) -> Result<()>

Load from a root hash (fetches tree structure from LMDB store)

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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