pub struct Tree<'repo> { /* private fields */ }
Expand description
A structure to represent a git tree
Implementations
sourceimpl<'repo> Tree<'repo>
impl<'repo> Tree<'repo>
sourcepub fn iter(&self) -> TreeIter<'_>ⓘNotable traits for TreeIter<'tree>impl<'tree> Iterator for TreeIter<'tree> type Item = TreeEntry<'tree>;
pub fn iter(&self) -> TreeIter<'_>ⓘNotable traits for TreeIter<'tree>impl<'tree> Iterator for TreeIter<'tree> type Item = TreeEntry<'tree>;
Returns an iterator over the entries in this tree.
sourcepub fn walk<C, T>(&self, mode: TreeWalkMode, callback: C) -> Result<(), Error> where
C: FnMut(&str, &TreeEntry<'_>) -> T,
T: Into<i32>,
pub fn walk<C, T>(&self, mode: TreeWalkMode, callback: C) -> Result<(), Error> where
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.
sourcepub fn get(&self, n: usize) -> Option<TreeEntry<'_>>
pub fn get(&self, n: usize) -> Option<TreeEntry<'_>>
Lookup a tree entry by its position in the tree
sourcepub fn get_name(&self, filename: &str) -> Option<TreeEntry<'_>>
pub fn get_name(&self, filename: &str) -> Option<TreeEntry<'_>>
Lookup a tree entry by its filename
sourcepub fn get_name_bytes(&self, filename: &[u8]) -> Option<TreeEntry<'_>>
pub fn get_name_bytes(&self, filename: &[u8]) -> Option<TreeEntry<'_>>
Lookup a tree entry by its filename, specified as bytes.
This allows for non-UTF-8 filenames.
sourcepub fn get_path(&self, path: &Path) -> Result<TreeEntry<'static>, Error>
pub fn get_path(&self, path: &Path) -> Result<TreeEntry<'static>, Error>
Retrieve a tree entry contained in a tree or in any of its subtrees, given its relative path.
sourcepub fn into_object(self) -> Object<'repo>
pub fn into_object(self) -> Object<'repo>
Consumes Commit to be returned as an Object
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more