[go: up one dir, main page]

Struct git2::Tree[][src]

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

A structure to represent a git tree

Implementations

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

pub fn iter(&self) -> TreeIter<'_>

Notable traits for TreeIter<'tree>

impl<'tree> Iterator for TreeIter<'tree> type Item = TreeEntry<'tree>;
[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.

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> Clone for Tree<'repo>[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

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

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

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?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

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.

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

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.