Struct git2::Tree

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

A structure to represent a git tree

Implementations

Get the id (SHA1) of a repository object

Get the number of entries listed in this tree.

Return true if there is not entry

Returns an iterator over the entries in this tree.

Traverse the entries in a tree and its subtrees in post or pre order. The callback function will be run on each node of the tree that’s walked. The return code of this function will determine how the walk continues.

libgit requires that the callback be an integer, where 0 indicates a successful visit, 1 skips the node, and -1 aborts the traversal completely. You may opt to use the enum TreeWalkResult instead.

let mut ct = 0;
tree.walk(TreeWalkMode::PreOrder, |_, entry| {
    assert_eq!(entry.name(), Some("foo"));
    ct += 1;
    TreeWalkResult::Ok
}).unwrap();
assert_eq!(ct, 1);

See libgit documentation for more information.

Lookup a tree entry by SHA value.

Lookup a tree entry by its position in the tree

Lookup a tree entry by its filename

Lookup a tree entry by its filename, specified as bytes.

This allows for non-UTF-8 filenames.

Retrieve a tree entry contained in a tree or in any of its subtrees, given its relative path.

Casts this Tree to be usable as an Object

Consumes Commit to be returned as an Object

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.