pub struct TreeBuilder { /* private fields */ }Expand description
Builds a single tree level: deduplicates entries by name and emits them in Git’s canonical order so the written object is byte-identical to Git’s.
Start from TreeBuilder::new (empty) or TreeBuilder::from_tree (edit
an existing level), upsert entries, then
build / write.
Implementations§
Source§impl TreeBuilder
impl TreeBuilder
pub fn new() -> Self
Sourcepub fn upsert(
&mut self,
name: impl Into<BString>,
kind: EntryKind,
oid: ObjectId,
)
pub fn upsert( &mut self, name: impl Into<BString>, kind: EntryKind, oid: ObjectId, )
Insert or replace the entry named name with one of Git’s canonical
kinds.
Sourcepub fn upsert_raw(&mut self, name: impl Into<BString>, mode: u32, oid: ObjectId)
pub fn upsert_raw(&mut self, name: impl Into<BString>, mode: u32, oid: ObjectId)
Insert or replace using a raw mode (for round-tripping non-canonical
modes); prefer upsert for normal entries.
Sourcepub fn remove(&mut self, name: &[u8]) -> bool
pub fn remove(&mut self, name: &[u8]) -> bool
Remove the entry named name, returning whether one was present.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn object_id(self, format: ObjectFormat) -> Result<ObjectId>
pub fn object_id(self, format: ObjectFormat) -> Result<ObjectId>
The OID this tree will have once written.
Trait Implementations§
Source§impl Clone for TreeBuilder
impl Clone for TreeBuilder
Source§fn clone(&self) -> TreeBuilder
fn clone(&self) -> TreeBuilder
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 TreeBuilder
impl Debug for TreeBuilder
Source§impl Default for TreeBuilder
impl Default for TreeBuilder
Source§fn default() -> TreeBuilder
fn default() -> TreeBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TreeBuilder
impl RefUnwindSafe for TreeBuilder
impl Send for TreeBuilder
impl Sync for TreeBuilder
impl Unpin for TreeBuilder
impl UnsafeUnpin for TreeBuilder
impl UnwindSafe for TreeBuilder
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