Struct git2::Tree [−][src]
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<'_>ⓘ
[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]
C: FnMut(&str, &TreeEntry<'_>) -> T,
T: Into<i32>,
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]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'repo> Debug for Tree<'repo>
[src]
impl<'repo> Drop for Tree<'repo>
[src]
impl<'repo, 'iter> IntoIterator for &'iter Tree<'repo>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,