pub struct Tree<'repo> { /* private fields */ }
Expand description
A structure to represent a git tree
Implementations§
Source§impl<'repo> Tree<'repo>
impl<'repo> Tree<'repo>
Sourcepub fn walk<C, T>(&self, mode: TreeWalkMode, callback: C) -> Result<(), Error>
pub fn walk<C, T>(&self, mode: TreeWalkMode, callback: C) -> Result<(), Error>
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.
libgit2 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 libgit2 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 this Tree to be returned as an Object
Trait Implementations§
Source§impl<'repo, 'iter> IntoIterator for &'iter Tree<'repo>
impl<'repo, 'iter> IntoIterator for &'iter Tree<'repo>
Auto Trait Implementations§
impl<'repo> Freeze for Tree<'repo>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more