pub struct Snapshot<'a> { /* private fields */ }Expand description
A tree hierarchy and one deterministic commit with no parents. All data and storage are borrowed; construction never allocates.
Implementations§
Source§impl<'a> Snapshot<'a>
impl<'a> Snapshot<'a>
Sourcepub fn new(
files: &'a [File<'a>],
tree_storage: &'a mut [u8],
commit_storage: &'a mut [u8],
) -> Result<Self>
pub fn new( files: &'a [File<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], ) -> Result<Self>
Build a flat snapshot of regular files. Existing buffer sizing and object IDs are preserved; this constructor needs only the raw root tree’s bytes.
Sourcepub fn new_with_commit(
files: &'a [File<'a>],
tree_storage: &'a mut [u8],
commit_storage: &'a mut [u8],
options: CommitOptions<'_>,
) -> Result<Self>
pub fn new_with_commit( files: &'a [File<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], options: CommitOptions<'_>, ) -> Result<Self>
Build a flat snapshot with custom root-commit metadata, using raw tree storage.
pub fn new_with_format( files: &'a [File<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], format: ObjectFormat, ) -> Result<Self>
pub fn new_with_commit_and_format( files: &'a [File<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], options: CommitOptions<'_>, format: ObjectFormat, ) -> Result<Self>
Sourcepub fn from_entries(
entries: &'a [Entry<'a>],
tree_storage: &'a mut [u8],
commit_storage: &'a mut [u8],
) -> Result<Self>
pub fn from_entries( entries: &'a [Entry<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], ) -> Result<Self>
Build nested trees with regular/executable files, symlinks, and empty trees. Entries at every level must be sorted using Entry::cmp_name, with no duplicate names. Storage needs the sum of every raw tree’s size plus four bytes per tree, including duplicate/empty trees. Depth is limited by MAX_TREE_DEPTH; excess depth returns Unsupported. Discard partial storage after any error. Git checkout does not materialize empty trees.
Sourcepub fn from_entries_with_commit(
entries: &'a [Entry<'a>],
tree_storage: &'a mut [u8],
commit_storage: &'a mut [u8],
options: CommitOptions<'_>,
) -> Result<Self>
pub fn from_entries_with_commit( entries: &'a [Entry<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], options: CommitOptions<'_>, ) -> Result<Self>
Build nested trees with custom root-commit metadata. Tree storage and validation follow from_entries; options are copied into commit_storage.
pub fn from_entries_with_format( entries: &'a [Entry<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], format: ObjectFormat, ) -> Result<Self>
pub fn from_entries_with_commit_and_format( entries: &'a [Entry<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], options: CommitOptions<'_>, format: ObjectFormat, ) -> Result<Self>
Sourcepub fn with_refs(self, head_ref: &'a str, refs: &'a [&'a str]) -> Result<Self>
pub fn with_refs(self, head_ref: &'a str, refs: &'a [&'a str]) -> Result<Self>
Configure the default branch and ref aliases for this snapshot’s commit. Names must be fully qualified, byte-sorted, unique, and free of path conflicts (e.g. refs/heads/a and refs/heads/a/b). Include head_ref in the slice. Ref configuration does not change any object ID or cache key.
Trait Implementations§
Source§impl Repository for Snapshot<'_>
impl Repository for Snapshot<'_>
Source§fn object_format(&self) -> ObjectFormat
fn object_format(&self) -> ObjectFormat
object_id.Source§fn head(&self) -> ObjectId
fn head(&self) -> ObjectId
head_state().id() when absence needs to be distinguished.fn head_ref(&self) -> &str
fn reference_count(&self) -> usize
fn reference_name(&self, index: usize) -> Option<&str>
fn object_count(&self) -> usize
Source§fn object(&self, index: usize) -> Option<Object<'_>>
fn object(&self, index: usize) -> Option<Object<'_>>
None and implement object_info, read_object, and object_id instead.fn head_state(&self) -> Head<'_>
fn object_info(&self, index: usize) -> Result<ObjectInfo>
Source§fn read_object(
&self,
index: usize,
offset: u64,
storage: &mut [u8],
) -> Result<usize>
fn read_object( &self, index: usize, offset: u64, storage: &mut [u8], ) -> Result<usize>
storage.len() body bytes starting at a byte offset.
Short reads are allowed. Return zero only at EOF or for empty storage.
Calls must be independent of earlier reads, enabling interleaved readers
and retries. Errors may modify storage but must not change the object.Source§fn object_id(&self, index: usize) -> Option<ObjectId>
fn object_id(&self, index: usize) -> Option<ObjectId>
ObjectHasher computes them incrementally with caller-owned scratch.