Skip to main content

Snapshot

Struct Snapshot 

Source
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>

Source

pub fn new( files: &'a [File<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], ) -> Result<Snapshot<'a>, Error>

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.

Source

pub fn new_with_commit( files: &'a [File<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], options: CommitOptions<'_>, ) -> Result<Snapshot<'a>, Error>

Build a flat snapshot with custom root-commit metadata, using raw tree storage.

Source

pub fn new_with_format( files: &'a [File<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], format: ObjectFormat, ) -> Result<Snapshot<'a>, Error>

Source

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<Snapshot<'a>, Error>

Source

pub fn from_entries( entries: &'a [Entry<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], ) -> Result<Snapshot<'a>, Error>

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.

Source

pub fn from_entries_with_commit( entries: &'a [Entry<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], options: CommitOptions<'_>, ) -> Result<Snapshot<'a>, Error>

Build nested trees with custom root-commit metadata. Tree storage and validation follow from_entries; options are copied into commit_storage.

Source

pub fn from_entries_with_format( entries: &'a [Entry<'a>], tree_storage: &'a mut [u8], commit_storage: &'a mut [u8], format: ObjectFormat, ) -> Result<Snapshot<'a>, Error>

Source

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<Snapshot<'a>, Error>

Source

pub fn with_refs( self, head_ref: &'a str, refs: &'a [&'a str], ) -> Result<Snapshot<'a>, Error>

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<'_>

Source§

fn object_format(&self) -> ObjectFormat

Fixed for the entire repository, including unborn HEAD. Defaults to SHA-1; SHA-256 providers must override this independently of object_id.
Source§

fn head(&self) -> ObjectId

Resolved commit ID, or the all-zero sentinel for an unborn HEAD. Use head_state().id() when absence needs to be distinguished.
Source§

fn head_ref(&self) -> &str

Source§

fn reference_count(&self) -> usize

Source§

fn reference_name(&self, index: usize) -> Option<&str>

Source§

fn object_count(&self) -> usize

Source§

fn object(&self, index: usize) -> Option<Object<'_>>

Optional borrowed-body fast path. Streaming providers can leave this as None and implement object_info, read_object, and object_id instead.
Source§

fn head_state(&self) -> Head<'_>

Source§

fn object_info(&self, index: usize) -> Result<ObjectInfo, Error>

Source§

fn read_object( &self, index: usize, offset: u64, storage: &mut [u8], ) -> Result<usize, Error>

Read at most 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>

Return an object’s ID. Streaming providers must supply precomputed IDs; ObjectHasher computes them incrementally with caller-owned scratch.
Source§

fn reference_id(&self, index: usize) -> Option<ObjectId>

Defaults preserve snapshot commit aliases. Override for independent tips.
Source§

fn reference_symbolic_target(&self, _index: usize) -> Option<&str>

Source§

fn reference_peeled(&self, _index: usize) -> Option<ObjectId>

Source§

fn find(&self, id: ObjectId) -> Option<Object<'_>>

Source§

fn find_index(&self, id: ObjectId) -> Option<usize>

Lookup without requiring a borrowed body. Metadata providers can index it.

Auto Trait Implementations§

§

impl<'a> Freeze for Snapshot<'a>

§

impl<'a> RefUnwindSafe for Snapshot<'a>

§

impl<'a> Send for Snapshot<'a>

§

impl<'a> Sync for Snapshot<'a>

§

impl<'a> Unpin for Snapshot<'a>

§

impl<'a> UnsafeUnpin for Snapshot<'a>

§

impl<'a> UnwindSafe for Snapshot<'a>

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 = !

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.