pub struct GitStorage { /* private fields */ }Expand description
Git storage backed by hashtree with LMDB persistence
Implementations§
Source§impl GitStorage
impl GitStorage
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open or create a git storage at the given path
Sourcepub fn has_object(&self, oid: &ObjectId) -> Result<bool>
pub fn has_object(&self, oid: &ObjectId) -> Result<bool>
Check if an object exists
Sourcepub fn read_object(&self, oid: &ObjectId) -> Result<GitObject>
pub fn read_object(&self, oid: &ObjectId) -> Result<GitObject>
Read an object by ID
Sourcepub fn write_object(&self, obj: &GitObject) -> Result<ObjectId>
pub fn write_object(&self, obj: &GitObject) -> Result<ObjectId>
Write an object, returning its ID
Sourcepub fn write_blob(&self, content: &[u8]) -> Result<ObjectId>
pub fn write_blob(&self, content: &[u8]) -> Result<ObjectId>
Write a blob, returning its ID
Sourcepub fn write_tree(&self, content: &[u8]) -> Result<ObjectId>
pub fn write_tree(&self, content: &[u8]) -> Result<ObjectId>
Write a tree, returning its ID
Sourcepub fn write_commit(&self, content: &[u8]) -> Result<ObjectId>
pub fn write_commit(&self, content: &[u8]) -> Result<ObjectId>
Write a commit, returning its ID
Sourcepub fn write_raw_object(
&self,
obj_type: ObjectType,
content: &[u8],
) -> Result<ObjectId>
pub fn write_raw_object( &self, obj_type: ObjectType, content: &[u8], ) -> Result<ObjectId>
Write raw object data (type + content already parsed)
Sourcepub fn list_objects(&self) -> Result<Vec<ObjectId>>
pub fn list_objects(&self) -> Result<Vec<ObjectId>>
List all object IDs
Sourcepub fn delete_ref(&self, name: &str) -> Result<bool>
pub fn delete_ref(&self, name: &str) -> Result<bool>
Delete a ref
Sourcepub fn resolve_ref(&self, name: &str) -> Result<ObjectId>
pub fn resolve_ref(&self, name: &str) -> Result<ObjectId>
Resolve a ref to its final object ID (follows symbolic refs)
Sourcepub fn list_refs_with_prefix(&self, prefix: &str) -> Result<Vec<NamedRef>>
pub fn list_refs_with_prefix(&self, prefix: &str) -> Result<Vec<NamedRef>>
List refs matching a prefix (e.g., “refs/heads/”)
Sourcepub fn compare_and_swap_ref(
&self,
name: &str,
expected: Option<&ObjectId>,
new_value: Option<&ObjectId>,
) -> Result<bool>
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
Sourcepub fn build_tree(&mut self) -> Result<[u8; 32]>
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
Sourcepub fn get_root_hash(&mut self) -> Result<String>
pub fn get_root_hash(&mut self) -> Result<String>
Get root hash as hex string
Sourcepub fn store(&self) -> &Arc<LmdbBlobStore>
pub fn store(&self) -> &Arc<LmdbBlobStore>
Get the underlying store
Sourcepub fn determine_default_branch(&self) -> Option<String>
pub fn determine_default_branch(&self) -> Option<String>
Determine the default branch for HEAD Priority: master > main > alphabetically first branch
Sourcepub fn extract_working_tree(
&self,
commit_oid: &ObjectId,
) -> Result<Vec<WorkingTreeEntry>>
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
Sourcepub fn load_from_root(&mut self, root_hash: &str) -> Result<()>
pub fn load_from_root(&mut self, root_hash: &str) -> Result<()>
Load from a root hash (fetches tree structure from LMDB store)