pub struct SourceTree {
pub path: PathBuf,
pub mode: String,
pub sha: String,
pub entry_type: TreeEntryType,
pub size: u32,
pub url: String,
pub children: Vec<SourceTree>,
}Expand description
A tree representing the directories and files of a GitHub repo.
Fields§
§path: PathBufThe path of the file relative to the root of the repository.
mode: StringThe unix permissions mode of the file, in numeric notation.
sha: StringThe SHA1 hash identifying this blob or tree.
This is NOT the same as the sha1 hash of the contents.
entry_type: TreeEntryTypeThe type of the entry.
size: u32The size of the entry in bytes, or 0 for blob entries.
url: StringThe API URL to call to get more information on this object.
- For TreeEntryType::Blob, this is the URL of the
Get a blobAPI call for this entry. - For TreeEntryType::Tree, this is the URL of the
Get a treeAPI call for this entry.
children: Vec<SourceTree>The children of this entry, if any.
Implementations§
Source§impl SourceTree
impl SourceTree
Sourcepub fn new(entry_type: TreeEntryType) -> SourceTree
pub fn new(entry_type: TreeEntryType) -> SourceTree
Create a new empty SourceTree with the given TreeEntryType.
Sourcepub async fn get<'p>(
path: &'p GithubBranchPath<'p>,
) -> Result<SourceTree, Error>
pub async fn get<'p>( path: &'p GithubBranchPath<'p>, ) -> Result<SourceTree, Error>
Obtain the entire SourceTree for a given GithubBranchPath.
Sourcepub fn resolve_blob(&self, path: &Path) -> Option<&SourceTree>
pub fn resolve_blob(&self, path: &Path) -> Option<&SourceTree>
Walks the tree to find a blob at the given path, if any.
Equivalent to resolve with find_blob as Some(true).
Sourcepub fn resolve_tree(&self, path: &Path) -> Option<&SourceTree>
pub fn resolve_tree(&self, path: &Path) -> Option<&SourceTree>
Walks the tree to find a tree (directory) at the given path, if any.
Equivalent to resolve with find_blob as Some(false).
Sourcepub fn resolve_any(&self, path: &Path) -> Option<&SourceTree>
pub fn resolve_any(&self, path: &Path) -> Option<&SourceTree>
Walks the tree to find a node at the given path, if any.
Equivalent to resolve with find_blob as None.
Sourcepub fn resolve(
&self,
path: &Path,
find_blob: Option<bool>,
) -> Option<&SourceTree>
pub fn resolve( &self, path: &Path, find_blob: Option<bool>, ) -> Option<&SourceTree>
Walks the tree to find an entry at the given path, if any.
- If
find_blobisSome(true), only blob entries will be returned. - If
find_blobisSome(false), only tree entries will be returned. - If
find_blobisNone, the first type of entry found will be returned.
Sourcepub fn iter<'tree>(&'tree self) -> SourceTreeIterator<'tree> ⓘ
pub fn iter<'tree>(&'tree self) -> SourceTreeIterator<'tree> ⓘ
Creates a SourceTreeIterator that will walk down this tree and return a pointer for each node found.
Sourcepub fn prune(
&self,
predicate: for<'a> fn(&'a &SourceTree) -> bool,
) -> SourceTree
pub fn prune( &self, predicate: for<'a> fn(&'a &SourceTree) -> bool, ) -> SourceTree
Creates a new SourceTree from this tree, only including child nodes where f returns true.
Trait Implementations§
Source§impl Clone for SourceTree
impl Clone for SourceTree
Source§fn clone(&self) -> SourceTree
fn clone(&self) -> SourceTree
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SourceTree
impl Debug for SourceTree
Source§impl PartialEq for SourceTree
impl PartialEq for SourceTree
impl StructuralPartialEq for SourceTree
Auto Trait Implementations§
impl Freeze for SourceTree
impl RefUnwindSafe for SourceTree
impl Send for SourceTree
impl Sync for SourceTree
impl Unpin for SourceTree
impl UnwindSafe for SourceTree
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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