[][src]Struct git2::Tree

pub struct Tree<'repo> { /* fields omitted */ }

A structure to represent a git tree

Methods

impl<'repo> Tree<'repo>[src]

pub fn id(&self) -> Oid[src]

Get the id (SHA1) of a repository object

pub fn len(&self) -> usize[src]

Get the number of entries listed in this tree.

pub fn is_empty(&self) -> bool[src]

Return true if there is not entry

Important traits for TreeIter<'tree>
pub fn iter(&self) -> TreeIter[src]

Returns an iterator over the entries in this tree.

pub fn walk<C, T>(&self, mode: TreeWalkMode, callback: C) -> Result<(), Error> where
    C: FnMut(&str, &TreeEntry) -> T,
    T: Into<i32>, 
[src]

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.

This example is not tested
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.

pub fn get_id(&self, id: Oid) -> Option<TreeEntry>[src]

Lookup a tree entry by SHA value.

pub fn get(&self, n: usize) -> Option<TreeEntry>[src]

Lookup a tree entry by its position in the tree

pub fn get_name(&self, filename: &str) -> Option<TreeEntry>[src]

Lookup a tree entry by its filename

pub fn get_path(&self, path: &Path) -> Result<TreeEntry<'static>, Error>[src]

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

pub fn as_object(&self) -> &Object<'repo>[src]

Casts this Tree to be usable as an Object

pub fn into_object(self) -> Object<'repo>[src]

Consumes Commit to be returned as an Object

Trait Implementations

impl<'repo> Drop for Tree<'repo>[src]

impl<'repo> Clone for Tree<'repo>[src]

impl<'repo, 'iter> IntoIterator for &'iter Tree<'repo>[src]

type Item = TreeEntry<'iter>

The type of the elements being iterated over.

type IntoIter = TreeIter<'iter>

Which kind of iterator are we turning this into?

impl<'repo> Debug for Tree<'repo>[src]

Auto Trait Implementations

impl<'repo> Unpin for Tree<'repo>

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

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

impl<'repo> UnwindSafe for Tree<'repo>

impl<'repo> RefUnwindSafe for Tree<'repo>

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]