pub struct Directory { /* private fields */ }
Expand description
A Directory
is the representation of a file system directory, for a given
git
tree.
The name of a directory can be retrieved via File::name
.
The Entries
of a directory can be retrieved via
Directory::entries
.
Implementations§
Source§impl Directory
impl Directory
Sourcepub fn path(&self) -> PathBuf
pub fn path(&self) -> PathBuf
Return the exact path for this Directory
, including the name
of the
directory itself.
The path is relative to the git repository root.
Sourcepub fn location(&self) -> &Path
pub fn location(&self) -> &Path
Return the Path
where this Directory
is located, relative to the
git repository root.
Sourcepub fn entries(&self, repo: &Repository) -> Result<Entries, Directory>
pub fn entries(&self, repo: &Repository) -> Result<Entries, Directory>
Sourcepub fn find_entry<P>(
&self,
path: &P,
repo: &Repository,
) -> Result<Entry, Directory>
pub fn find_entry<P>( &self, path: &P, repo: &Repository, ) -> Result<Entry, Directory>
Find the Entry
found at a non-empty path
, if it exists.
Sourcepub fn find_file<P>(
&self,
path: &P,
repo: &Repository,
) -> Result<File, Directory>
pub fn find_file<P>( &self, path: &P, repo: &Repository, ) -> Result<File, Directory>
Find the Oid
, for a File
, found at path
, if it exists.
Sourcepub fn find_directory<P>(
&self,
path: &P,
repo: &Repository,
) -> Result<Self, Directory>
pub fn find_directory<P>( &self, path: &P, repo: &Repository, ) -> Result<Self, Directory>
Find the Directory
found at path
, if it exists.
If path
is ROOT_DIR
(i.e. an empty path), returns self.
Sourcepub fn size(&self, repo: &Repository) -> Result<usize, Directory>
pub fn size(&self, repo: &Repository) -> Result<usize, Directory>
Get the total size, in bytes, of a Directory
. The size is
the sum of all files that can be reached from this Directory
.
Sourcepub fn traverse<Error, B, F>(
&self,
repo: &Repository,
initial: B,
f: &mut F,
) -> Result<B, Error>
pub fn traverse<Error, B, F>( &self, repo: &Repository, initial: B, f: &mut F, ) -> Result<B, Error>
Traverse the entire Directory
using the initial
accumulator and the function f
.
For each Entry::Directory
this will recursively call
Directory::traverse
and obtain its Entries
.
Error
is the error type of the fallible function.
B
is the type of the accumulator.
F
is the fallible function that takes the accumulator and
the next Entry
, possibly providing the next accumulator
value.