pub struct WorkspaceIndex {
pub version: u32,
pub commit_cid: Option<CommitCid>,
pub entries: Vec<IndexEntry>,
}Expand description
Workspace index snapshot.
Fields§
§version: u32§commit_cid: Option<CommitCid>§entries: Vec<IndexEntry>Implementations§
Source§impl WorkspaceIndex
impl WorkspaceIndex
pub const VERSION: u32 = 1
pub fn new(commit_cid: Option<CommitCid>, entries: Vec<IndexEntry>) -> Self
Sourcepub fn upsert_entry(&mut self, entry: IndexEntry)
pub fn upsert_entry(&mut self, entry: IndexEntry)
Insert or replace a precomputed entry.
Sourcepub fn unstage_file(
&mut self,
rel_path: &str,
head_entry: Option<&IndexEntry>,
) -> Result<()>
pub fn unstage_file( &mut self, rel_path: &str, head_entry: Option<&IndexEntry>, ) -> Result<()>
Unstage a file (reset to HEAD state or remove if new).
If head_entry is Some, replaces the current entry with the HEAD version.
If head_entry is None, removes the entry from the index entirely.
§Arguments
rel_path- The relative path of the file to unstagehead_entry- The entry from HEAD commit, or None if the file is new
Sourcepub fn get(&self, path: &str) -> Option<&IndexEntry>
pub fn get(&self, path: &str) -> Option<&IndexEntry>
Get entry by path.
Sourcepub fn has_staged_changes(&self, head_entries: &[IndexEntry]) -> bool
pub fn has_staged_changes(&self, head_entries: &[IndexEntry]) -> bool
Check if index has uncommitted changes vs HEAD.
Returns true if:
- Any entry in the index differs from HEAD (by path or content_hash)
- Any entry exists in HEAD but not in the index
- Any entry exists in the index but not in HEAD
Sourcepub fn iter(&self) -> impl Iterator<Item = &IndexEntry>
pub fn iter(&self) -> impl Iterator<Item = &IndexEntry>
Iterate over all entries.
Trait Implementations§
Source§impl Clone for WorkspaceIndex
impl Clone for WorkspaceIndex
Source§fn clone(&self) -> WorkspaceIndex
fn clone(&self) -> WorkspaceIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WorkspaceIndex
impl Debug for WorkspaceIndex
Source§impl<'de> Deserialize<'de> for WorkspaceIndex
impl<'de> Deserialize<'de> for WorkspaceIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for WorkspaceIndex
impl RefUnwindSafe for WorkspaceIndex
impl Send for WorkspaceIndex
impl Sync for WorkspaceIndex
impl Unpin for WorkspaceIndex
impl UnsafeUnpin for WorkspaceIndex
impl UnwindSafe for WorkspaceIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more