Struct git2::TreeBuilder

source ·
pub struct TreeBuilder<'repo> { /* private fields */ }
Expand description

Constructor for in-memory trees (low-level)

You probably want to use build::TreeUpdateBuilder instead.

This is the more raw of the two tree update facilities. It handles only one level of a nested tree structure at a time. Each path passed to insert etc. must be a single component.

Implementations§

source§

impl<'repo> TreeBuilder<'repo>

source

pub fn clear(&mut self) -> Result<(), Error>

Clear all the entries in the builder

source

pub fn len(&self) -> usize

Get the number of entries

source

pub fn is_empty(&self) -> bool

Return true if there is no entry

source

pub fn get<P>(&self, filename: P) -> Result<Option<TreeEntry<'_>>, Error>
where P: IntoCString,

Get en entry from the builder from its filename

source

pub fn insert<P: IntoCString>( &mut self, filename: P, oid: Oid, filemode: i32, ) -> Result<TreeEntry<'_>, Error>

Add or update an entry in the builder

No attempt is made to ensure that the provided Oid points to an object of a reasonable type (or any object at all).

The mode given must be one of 0o040000, 0o100644, 0o100755, 0o120000 or 0o160000 currently.

source

pub fn remove<P: IntoCString>(&mut self, filename: P) -> Result<(), Error>

Remove an entry from the builder by its filename

source

pub fn filter<F>(&mut self, filter: F) -> Result<(), Error>
where F: FnMut(&TreeEntry<'_>) -> bool,

Selectively remove entries from the tree

Values for which the filter returns true will be kept. Note that this behavior is different from the libgit2 C interface.

source

pub fn write(&self) -> Result<Oid, Error>

Write the contents of the TreeBuilder as a Tree object and return its Oid

Trait Implementations§

source§

impl<'repo> Drop for TreeBuilder<'repo>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'repo> Freeze for TreeBuilder<'repo>

§

impl<'repo> RefUnwindSafe for TreeBuilder<'repo>

§

impl<'repo> !Send for TreeBuilder<'repo>

§

impl<'repo> !Sync for TreeBuilder<'repo>

§

impl<'repo> Unpin for TreeBuilder<'repo>

§

impl<'repo> UnwindSafe for TreeBuilder<'repo>

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T