pub struct BinaryIndex {
pub entries: HashMap<String, BinaryIndexEntry>,
}Expand description
Binary index — high-performance staging area
Fields§
§entries: HashMap<String, BinaryIndexEntry>Implementations§
Source§impl BinaryIndex
impl BinaryIndex
pub fn new() -> Self
Sourcepub fn add(
&mut self,
path: String,
hash: String,
mode: String,
size: u64,
mtime: i64,
)
pub fn add( &mut self, path: String, hash: String, mode: String, size: u64, mtime: i64, )
Add or update an entry
Sourcepub fn remove(&mut self, path: &str) -> Option<BinaryIndexEntry>
pub fn remove(&mut self, path: &str) -> Option<BinaryIndexEntry>
Remove an entry
Sourcepub fn sorted_entries(&self) -> Vec<&BinaryIndexEntry>
pub fn sorted_entries(&self) -> Vec<&BinaryIndexEntry>
Get sorted entries
Sourcepub fn save(&self, path: &Path) -> Result<(), String>
pub fn save(&self, path: &Path) -> Result<(), String>
Save to binary format
Format: Header: LITX(4) + version(4) + entry_count(4) Each entry: path_len(4) + path_bytes + hash_len(4) + hash_bytes + mode_len(2) + mode_bytes + size(8) + mtime(8)
Sourcepub fn from_json_index(index: &Index) -> Self
pub fn from_json_index(index: &Index) -> Self
Convert from the JSON-based Index
Trait Implementations§
Source§impl Clone for BinaryIndex
impl Clone for BinaryIndex
Source§fn clone(&self) -> BinaryIndex
fn clone(&self) -> BinaryIndex
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 BinaryIndex
impl Debug for BinaryIndex
Auto Trait Implementations§
impl Freeze for BinaryIndex
impl RefUnwindSafe for BinaryIndex
impl Send for BinaryIndex
impl Sync for BinaryIndex
impl Unpin for BinaryIndex
impl UnsafeUnpin for BinaryIndex
impl UnwindSafe for BinaryIndex
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