[−][src]Struct radicle_surf::file_system::Directory
A Directory
consists of its Label
and its entries.
The entries are a set of DirectoryContents
and there should be at least one entry.
This is because empty directories do not generally exist in VCSes.
Fields
name: Label
entries: NonEmpty<DirectoryContents>
Methods
impl Directory
[src]
pub fn size(&self) -> usize
[src]
Get the total size, in bytes, of a Directory
. The size is
the sum of all files that can be reached from this Directory
.
Examples
use radicle_surf::file_system::{Directory, DirectoryContents, File, Label}; use radicle_surf::file_system::unsound; let files = ( DirectoryContents::file(unsound::label::new("main.rs"), b"println!(\"Hello, world!\")"), vec![DirectoryContents::file(unsound::label::new("lib.rs"), b"struct Hello(String)")], ).into(); let directory = Directory { name: Label::root(), entries: files, }; assert_eq!(directory.size(), 45);
use nonempty::NonEmpty; use radicle_surf::file_system::{Directory, DirectoryContents, File, Label}; use radicle_surf::file_system::unsound; let mut entries: NonEmpty<DirectoryContents> = ( DirectoryContents::file(unsound::label::new("main.rs"), b"println!(\"Hello, world!\")"), vec![DirectoryContents::file(unsound::label::new("lib.rs"), b"struct Hello(String)")], ).into(); let subdir = DirectoryContents::sub_directory(Directory { name: unsound::label::new("test"), entries: NonEmpty::new(DirectoryContents::file( unsound::label::new("mod.rs"), b"assert_eq!(1 + 1, 2);", )), }); entries.push(subdir); let directory = Directory { name: Label::root(), entries: entries, }; assert_eq!(directory.size(), 66);
pub fn list_directory(&self) -> Vec<(Label, SystemType)>
[src]
List the current Directory
's files and sub-directories.
pub fn find_file(&self, path: &Path) -> Option<File>
[src]
Find a File
in the directory given the Path
to
the File
.
This operation fails if the path does not lead to
the File
.
pub fn find_directory(&self, path: &Path) -> Option<Self>
[src]
Find a Directory
in the directory given the Path
to
the Directory
.
This operation fails if the path does not lead to
the Directory
.
Trait Implementations
impl Clone for Directory
[src]
impl Debug for Directory
[src]
impl Eq for Directory
[src]
impl PartialEq<Directory> for Directory
[src]
impl StructuralEq for Directory
[src]
impl StructuralPartialEq for Directory
[src]
Auto Trait Implementations
impl RefUnwindSafe for Directory
impl Send for Directory
impl Sync for Directory
impl Unpin for Directory
impl UnwindSafe for Directory
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,
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.
fn to_owned(&self) -> T
[src]
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.
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>,