DirDescendants

Struct DirDescendants 

Source
pub struct DirDescendants<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P> = NoFilter, P: PathType + ?Sized = Path> { /* private fields */ }
Expand description

A structure representing the descendants of a directory.

This is different from DirChildren, as the descendants include all files and folders within the directory, not just the immediate children, as is the case with DirChildren.

The F type parameter allows for custom filtering of the descendants, as follows:

  • its FolderFilter implementation tells us whether to attempt to parse a specific folder as T, storing it into the result set.
  • its FolderRecurseFilter tells us whether to recurse into a specific folder, but not necessarily parse it as T.
  • its FileFilter implementation tells us whether to attempt to parse a specific file as T, storing it into the result set.

* note that FolderFilter and FolderRecurseFilter may both allow the same path, in which case we will both recurse into the folder, and attempt to parse it as a T.

Implementations§

Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> DirDescendants<T, F, P>

Source

pub fn new(descendants: Vec<DirDescendant<T, P>>) -> Self

Create a new DirDescendants instance from a list of DirDescendants.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<(), NoFilter>::new(vec![]);
assert!(descendants.is_empty());

let descendants = DirDescendants::<(), NoFilter>::new(vec![
  DirDescendant::new("child1", "child1", "child1", ()),
  DirDescendant::new("child2", "child2", "child2", ()),
]);
assert_eq!(descendants.len(), 2);
Source

pub fn len(&self) -> usize

Returns the number of descendants.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<(), NoFilter>::new(vec![]);
assert_eq!(descendants.len(), 0);

let descendants = DirDescendants::<(), NoFilter>::new(vec![
  DirDescendant::new("child1", "child1", "child1", ()),
  DirDescendant::new("child2", "child2", "child2", ()),
]);
assert_eq!(descendants.len(), 2);
Source

pub fn is_empty(&self) -> bool

Returns whether there are no descendants.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};
let descendants = DirDescendants::<(), NoFilter>::new(vec![]);
assert_eq!(descendants.is_empty(), true);

let descendants = DirDescendants::<(), NoFilter>::new(vec![
  DirDescendant::new("child1", "child1", "child1", ()),
  DirDescendant::new("child2", "child2", "child2", ()),
]);
assert_eq!(descendants.is_empty(), false);
Source

pub fn iter(&self) -> DirDescendantsIter<'_, T, P>

Returns an iterator over the descendants.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<(), NoFilter>::new(vec![]);
let mut i = descendants.iter();
assert_eq!(i.next(), None);

let descendants = DirDescendants::<(), NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", ()),
    DirDescendant::new("child2", "child2", "child2", ()),
]);
let mut i = descendants.iter();
assert_eq!(i.next(), Some(&DirDescendant::new("child1", "child1", "child1", ())));
assert_eq!(i.next(), Some(&DirDescendant::new("child2", "child2", "child2", ())));
assert_eq!(i.next(), None);
Source

pub fn iter_mut(&mut self) -> DirDescendantsIterMut<'_, T, P>

Returns an iterator over the mutable descendants.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<(), NoFilter>::new(vec![]);
let mut i = descendants.iter_mut();
assert_eq!(i.next(), None);

let mut descendants = DirDescendants::<(), NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", ()),
    DirDescendant::new("child2", "child2", "child2", ()),
]);
let mut i = descendants.iter_mut();
assert_eq!(i.next(), Some(&mut DirDescendant::new("child1", "child1", "child1", ())));
assert_eq!(i.next(), Some(&mut DirDescendant::new("child2", "child2", "child2", ())));
assert_eq!(i.next(), None);
Source

pub fn get(&self, index: usize) -> Option<&DirDescendant<T, P>>

Returns the descendant at the given index, or None if out of bounds.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<(), NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", ()),
    DirDescendant::new("child2", "child2", "child2", ()),
]);

assert_eq!(descendants.len(), 2);
assert_eq!(descendants.get(0), Some(&DirDescendant::new("child1", "child1", "child1", ())));
assert_eq!(descendants.get(1), Some(&DirDescendant::new("child2", "child2", "child2", ())));
assert_eq!(descendants.get(2), None);
assert_eq!(descendants.get(100), None);
Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut DirDescendant<T, P>>

Returns a mutable reference to the descendant at the given index, or None if out of bounds. This is a mutable version of get.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<(), NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", ()),
    DirDescendant::new("child2", "child2", "child2", ()),
]);

assert_eq!(descendants.len(), 2);
assert_eq!(descendants.get_mut(0), Some(&mut DirDescendant::new("child1", "child1", "child1", ())));
assert_eq!(descendants.get_mut(1), Some(&mut DirDescendant::new("child2", "child2", "child2", ())));
assert_eq!(descendants.get_mut(2), None);
assert_eq!(descendants.get_mut(100), None);
Source

pub fn get_by_name( &self, name: impl AsRef<P::PathSegmentRef>, ) -> Option<&DirDescendant<T, P>>

Returns the descendant with the given name, or None if not found.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_by_name("child1"), Some(&DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into())));
assert_eq!(descendants.get_by_name("child2"), Some(&DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into())));
assert_eq!(descendants.get_by_name("child3"), None);
assert_eq!(descendants.get_by_name("nonexistent"), None);
Source

pub fn get_by_name_mut( &mut self, name: impl AsRef<P::PathSegmentRef>, ) -> Option<&mut DirDescendant<T, P>>

Returns a mutable reference to the descendant with the given name, or None if not found. This is a mutable version of get_by_name.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_by_name_mut("child1"), Some(&mut DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into())));
assert_eq!(descendants.get_by_name_mut("child2"), Some(&mut DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into())));
assert_eq!(descendants.get_by_name_mut("child3"), None);
assert_eq!(descendants.get_by_name_mut("nonexistent"), None);
Source

pub fn get_value_by_name( &self, name: impl AsRef<P::PathSegmentRef>, ) -> Option<&T>

Returns the value of the descendant with the given name, or None if not found.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_value_by_name("child1"), Some(&"value1".into()));
assert_eq!(descendants.get_value_by_name("child2"), Some(&"value2".into()));
assert_eq!(descendants.get_value_by_name("child3"), None);
assert_eq!(descendants.get_value_by_name("nonexistent"), None);
Source

pub fn get_value_by_name_mut( &mut self, name: impl AsRef<P::PathSegmentRef>, ) -> Option<&mut T>

Returns a mutable reference to the value of the descendant with the given name, or None if not found. This is a mutable version of get_value_by_name.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_value_by_name_mut("child1"), Some(&mut "value1".into()));
assert_eq!(descendants.get_value_by_name_mut("child2"), Some(&mut "value2".into()));
assert_eq!(descendants.get_value_by_name_mut("child3"), None);
assert_eq!(descendants.get_value_by_name_mut("nonexistent"), None);
Source

pub fn get_by_path(&self, path: impl AsRef<P>) -> Option<&DirDescendant<T, P>>
where P: PartialEq,

Returns the descendant with the given path, or None if not found.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_by_path("root/a/b/child1"), Some(&DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into())));
assert_eq!(descendants.get_by_path("root/a/b/child2"), Some(&DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into())));
assert_eq!(descendants.get_by_path("root/a/b/child3"), None);
assert_eq!(descendants.get_by_path("nonexistent"), None);
Source

pub fn get_by_path_mut( &mut self, path: impl AsRef<P>, ) -> Option<&mut DirDescendant<T, P>>
where P: PartialEq,

Returns a mutable reference to the descendant with the given path, or None if not found. This is a mutable version of get_by_path.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_by_path_mut("root/a/b/child1"), Some(&mut DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into())));
assert_eq!(descendants.get_by_path_mut("root/a/b/child2"), Some(&mut DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into())));
assert_eq!(descendants.get_by_path_mut("root/a/b/child3"), None);
assert_eq!(descendants.get_by_path_mut("nonexistent"), None);
Source

pub fn get_value_by_path(&self, path: impl AsRef<P>) -> Option<&T>
where P: PartialEq,

Returns the value of the descendant with the given path, or None if not found.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_value_by_path("root/a/b/child1"), Some(&"value1".into()));
assert_eq!(descendants.get_value_by_path("root/a/b/child2"), Some(&"value2".into()));
assert_eq!(descendants.get_value_by_path("root/a/b/child3"), None);
assert_eq!(descendants.get_value_by_path("nonexistent"), None);
Source

pub fn get_value_by_path_mut(&mut self, path: impl AsRef<P>) -> Option<&mut T>
where P: PartialEq,

Returns a mutable reference to the value of the descendant with the given path, or None if not found. This is a mutable version of get_value_by_path.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_value_by_path_mut("root/a/b/child1"), Some(&mut "value1".into()));
assert_eq!(descendants.get_value_by_path_mut("root/a/b/child2"), Some(&mut "value2".into()));
assert_eq!(descendants.get_value_by_path_mut("root/a/b/child3"), None);
assert_eq!(descendants.get_value_by_path_mut("nonexistent"), None);
Source

pub fn get_by_relative_path( &self, path: impl AsRef<P>, ) -> Option<&DirDescendant<T, P>>
where P: PartialEq,

Returns the descendant with the given path relative to the ascendant, or None if not found.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_by_relative_path("a/b/child1"), Some(&DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into())));
assert_eq!(descendants.get_by_relative_path("a/b/child2"), Some(&DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into())));
assert_eq!(descendants.get_by_relative_path("a/b/child3"), None);
assert_eq!(descendants.get_by_relative_path("nonexistent"), None);
Source

pub fn get_by_relative_path_mut( &mut self, path: impl AsRef<P>, ) -> Option<&mut DirDescendant<T, P>>
where P: PartialEq,

Returns a mutable reference to the descendant with the given path relative to the ascendant, or None if not found. This is a mutable version of get_by_relative_path.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_by_relative_path_mut("a/b/child1"), Some(&mut DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into())));
assert_eq!(descendants.get_by_relative_path_mut("a/b/child2"), Some(&mut DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into())));
assert_eq!(descendants.get_by_relative_path_mut("a/b/child3"), None);
assert_eq!(descendants.get_by_relative_path_mut("nonexistent"), None);
Source

pub fn get_value_by_relative_path(&self, path: impl AsRef<P>) -> Option<&T>
where P: PartialEq,

Returns the value of the descendant with the given path relative to the ascendant, or None if not found.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_value_by_relative_path("a/b/child1"), Some(&"value1".into()));
assert_eq!(descendants.get_value_by_relative_path("a/b/child2"), Some(&"value2".into()));
assert_eq!(descendants.get_value_by_relative_path("a/b/child3"), None);
assert_eq!(descendants.get_value_by_relative_path("nonexistent"), None);
Source

pub fn get_value_by_relative_path_mut( &mut self, path: impl AsRef<P>, ) -> Option<&mut T>
where P: PartialEq,

Returns a mutable reference to the value of the descendant with the given path relative to the ascendant, or None if not found. This is a mutable version of get_value_by_relative_path.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".into()),
    DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2".into()),
]);

assert_eq!(descendants.get_value_by_relative_path_mut("a/b/child1"), Some(&mut "value1".into()));
assert_eq!(descendants.get_value_by_relative_path_mut("a/b/child2"), Some(&mut "value2".into()));
assert_eq!(descendants.get_value_by_relative_path_mut("a/b/child3"), None);
assert_eq!(descendants.get_value_by_relative_path_mut("nonexistent"), None);
Source

pub fn map<U>(self, f: impl FnMut(T) -> U) -> DirDescendants<U, F, P>

Maps the descendants to another type.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let descendants = DirDescendants::<String, NoFilter>::new(vec![
  DirDescendant::new("child1", "root/a/b/child1", "a/b/child1", "value1".to_string()),
  DirDescendant::new("child2", "root/a/b/child2", "a/b/child2", "value2abc1000".to_string()),
]);

let mapped = descendants.map(|s| s.len());
assert_eq!(mapped.len(), 2);
assert_eq!(mapped.get(0).unwrap().value(), &6); // "value1".len() == 6
assert_eq!(mapped.get(1).unwrap().value(), &13); // "value2abc1000".len() == 13
assert_eq!(mapped.get(2), None);
assert_eq!(mapped.get(100), None);
Source

pub fn map_filter<F2: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>>( self, ) -> DirDescendants<T, F2, P>

Maps the filter type to another type.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant, FileFilter, FolderFilter, FolderRecurseFilter}, NoFilter};

struct MyFilter;

impl FileFilter for MyFilter {
    fn allows(_file: &std::path::Path) -> bool { true }
}
impl FolderFilter for MyFilter {
    fn allows(_folder: &std::path::Path) -> bool { true }
}
impl FolderRecurseFilter for MyFilter {
    fn allows(_folder: &std::path::Path) -> bool { true }
}

let descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", "value1".to_string()),
    DirDescendant::new("child2", "child2", "child2", "value2".to_string()),
]);
let descendants_with_my_filter: DirDescendants<String, MyFilter> = descendants.map_filter::<MyFilter>();
Source

pub fn push(&mut self, descendant: DirDescendant<T, P>)

Appends a descendant to the end of the list.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![]);
assert!(descendants.is_empty());

descendants.push(DirDescendant::new("child1", "child1", "child1", "value1".to_string()));
assert_eq!(descendants.len(), 1);
let mut i = descendants.iter();
assert_eq!(i.next(), Some(&DirDescendant::new("child1", "child1", "child1", "value1".to_string())));
assert_eq!(i.next(), None);

descendants.push(DirDescendant::new("child2", "child2", "child2", "value2".to_string()));
assert_eq!(descendants.len(), 2);
let mut i = descendants.iter();
assert_eq!(i.next(), Some(&DirDescendant::new("child1", "child1", "child1", "value1".to_string())));
assert_eq!(i.next(), Some(&DirDescendant::new("child2", "child2", "child2", "value2".to_string())));
assert_eq!(i.next(), None);
Source

pub fn retain(&mut self, f: impl FnMut(&DirDescendant<T, P>) -> bool)

Retains only the descendants specified by the predicate.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", "value1".to_string()),
    DirDescendant::new("child2", "child2", "child2", "value2".to_string()),
    DirDescendant::new("child3", "child3", "child3", "value3".to_string()),
]);

descendants.retain(|d| d.name() == "child2");
assert_eq!(descendants.len(), 1);
assert_eq!(descendants.get(0).unwrap().name(), "child2");
Source

pub fn drain( &mut self, range: impl RangeBounds<usize>, ) -> DirDescendantsDrain<'_, T, P>

Drains the descendants in the specified range.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", "value1".to_string()),
    DirDescendant::new("child2", "child2", "child2", "value2".to_string()),
    DirDescendant::new("child3", "child3", "child3", "value3".to_string()),
]);

let drained: Vec<_> = descendants.drain(0..2).collect();
assert_eq!(drained, vec![
    DirDescendant::new("child1", "child1", "child1", "value1".to_string()),
    DirDescendant::new("child2", "child2", "child2", "value2".to_string()),
]);
assert_eq!(descendants.len(), 1);
assert_eq!(descendants.get(0).unwrap().name(), "child3");
Source

pub fn extract_if<'a, Fi>( &'a mut self, range: impl RangeBounds<usize>, f: Fi, ) -> DirDescendantsExtractIf<'a, T, P, Fi>
where Fi: FnMut(&mut DirDescendant<T, P>) -> bool,

Extracts the descendants in the specified range that satisfy the predicate.

§Examples
use dir_structure::{dir_descendants::{DirDescendants, DirDescendant}, NoFilter};

let mut descendants = DirDescendants::<String, NoFilter>::new(vec![
    DirDescendant::new("child1", "child1", "child1", "value1".to_string()),
    DirDescendant::new("child2", "child2", "child2", "value2".to_string()),
    DirDescendant::new("child3", "child3", "child3", "value3".to_string()),
    DirDescendant::new("child4", "child4", "child4", "value4".to_string()),
]);

let extracted: Vec<_> = descendants.extract_if(1..4, |d| d.name() == "child2" || d.name() == "child4").collect();
assert_eq!(extracted, vec![
    DirDescendant::new("child2", "child2", "child2", "value2".to_string()),
    DirDescendant::new("child4", "child4", "child4", "value4".to_string()),
]);
assert_eq!(descendants.len(), 2);
assert_eq!(descendants.get(0).unwrap().name(), "child1");
assert_eq!(descendants.get(1).unwrap().name(), "child3");

Trait Implementations§

Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> AssertEq for DirDescendants<T, F, P>
where for<'__trivial> Vec<DirDescendant<T, P>>: AssertEq<Vec<DirDescendant<T, P>>> + Debug, for<'__trivial> PhantomData<F>: AssertEq<PhantomData<F>> + Debug,

Source§

fn assert_eq( &self, other: &Self, path: &mut AssertPath, init_left: &impl Display, init_right: &impl Display, )

Asserts that self is equal to other, panicking if they are not equal. Read more
Source§

impl<T: Clone, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> Clone for DirDescendants<T, F, P>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> Debug for DirDescendants<T, F, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> Default for DirDescendants<T, F, P>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, F: FolderFilter + FolderRecurseFilter + FileFilter> DynamicHasField for DirDescendants<T, F>

Source§

type Inner = T

Available on crate feature resolve-path only.
The type of the field.
Source§

fn resolve_path<P: OwnedPathType>(p: P, name: &str) -> P

Available on crate feature resolve-path only.
How to resolve the path for the field, from the path of Self, given the name passed into the resolve_path! macro.
Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> Extend<DirDescendant<T, P>> for DirDescendants<T, F, P>

Source§

fn extend<I: IntoIterator<Item = DirDescendant<T, P>>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> From<Vec<DirDescendant<T, P>>> for DirDescendants<T, F, P>

Source§

fn from(descendants: Vec<DirDescendant<T, P>>) -> Self

Converts to this type from the input type.
Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> FromIterator<DirDescendant<T, P>> for DirDescendants<T, F, P>

Source§

fn from_iter<I: IntoIterator<Item = DirDescendant<T, P>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a, T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> IntoIterator for &'a DirDescendants<T, F, P>

Source§

type Item = &'a DirDescendant<T, P>

The type of the elements being iterated over.
Source§

type IntoIter = DirDescendantsIter<'a, T, P>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> IntoIterator for &'a mut DirDescendants<T, F, P>

Source§

type Item = &'a mut DirDescendant<T, P>

The type of the elements being iterated over.
Source§

type IntoIter = DirDescendantsIterMut<'a, T, P>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> IntoIterator for DirDescendants<T, F, P>

Source§

type Item = DirDescendant<T, P>

The type of the elements being iterated over.
Source§

type IntoIter = DirDescendantsIntoIter<T, P>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq, F: PartialEq + FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PartialEq + PathType + ?Sized> PartialEq for DirDescendants<T, F, P>

Source§

fn eq(&self, other: &DirDescendants<T, F, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'vfs, Vfs: Vfs<'vfs>, T: ReadFrom<'vfs, Vfs>, F: FolderFilter<Vfs::Path> + FolderRecurseFilter<Vfs::Path> + FileFilter<Vfs::Path> + 'vfs> ReadFrom<'vfs, Vfs> for DirDescendants<T, F, Vfs::Path>

Source§

fn read_from(path: &Vfs::Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<Self, Vfs>

Reads the structure from the specified path, which can be either a file or a directory.
Source§

impl<'vfs, P: PathType + ?Sized + 'vfs, Vfs: VfsAsync<Path = P> + 'static, T: ReadFromAsync<'vfs, Vfs> + Send + 'static, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P> + 'vfs> ReadFromAsync<'vfs, Vfs> for DirDescendants<T, F, P>
where for<'f> Vfs::IsDirFuture<'f>: Future<Output = VfsResult<bool, Vfs>> + Send + 'f,

Available on crate feature async only.
Source§

type Future = Pin<Box<dyn Future<Output = Result<DirDescendants<T, F, P>, Error<<<Vfs as VfsCore>::Path as PathType>::OwnedPath>>> + Send + 'vfs>> where Self: 'vfs

The future type returned by the async read function.
Source§

fn read_from_async(path: P::OwnedPath, vfs: Pin<&'vfs Vfs>) -> Self::Future

Asynchronously reads the structure from the specified path, which can be either a file or a directory.
Source§

impl<'vfs, Vfs: WriteSupportingVfs<'vfs>, T: WriteTo<'vfs, Vfs> + 'vfs, F: FileFilter<Vfs::Path> + FolderRecurseFilter<Vfs::Path> + FolderFilter<Vfs::Path> + 'vfs> WriteTo<'vfs, Vfs> for DirDescendants<T, F, Vfs::Path>

Source§

fn write_to(&self, path: &Vfs::Path, vfs: Pin<&'vfs Vfs>) -> VfsResult<(), Vfs>

Writes the structure to the specified path.
Source§

impl<'vfs, Vfs: WriteSupportingVfsAsync + 'vfs, T: WriteToAsync<'vfs, Vfs> + Send + 'vfs, F: FileFilter<Vfs::Path> + FolderRecurseFilter<Vfs::Path> + FolderFilter<Vfs::Path> + Send + 'vfs> WriteToAsync<'vfs, Vfs> for DirDescendants<T, F, Vfs::Path>

Available on crate feature async only.
Source§

type Future = Pin<Box<dyn Future<Output = Result<(), Error<<<Vfs as VfsCore>::Path as PathType>::OwnedPath>>> + Send + 'vfs>>

The future type returned by the async write function.
Source§

fn write_to_async( self, path: <<Vfs as VfsCore>::Path as PathType>::OwnedPath, vfs: Pin<&'vfs Vfs>, ) -> Self::Future

Asynchronously writes the structure to the specified path.
Source§

impl<'vfs, Vfs: WriteSupportingVfsAsync<Path = P> + 'static, P: ?Sized + PathType, T: WriteToAsyncRef<'vfs, Vfs> + Sync + 'static, F: FileFilter<P> + FolderRecurseFilter<P> + FolderFilter<P> + Sync + 'vfs> WriteToAsyncRef<'vfs, Vfs> for DirDescendants<T, F, P>
where for<'r> T::Future<'r>: Future<Output = VfsResult<(), Vfs>> + Unpin + 'r,

Available on crate feature async only.
Source§

type Future<'r> = DirDescendantsWriteRefFuture<'r, 'vfs, Vfs, T> where Self: 'r, Vfs: 'r, T: 'r, 'vfs: 'r

The future type returned by the async write function.
Source§

fn write_to_async_ref<'r>( &'r self, path: P::OwnedPath, vfs: Pin<&'r Vfs>, ) -> Self::Future<'r>
where 'vfs: 'r,

Asynchronously writes the structure to the specified path.
Source§

impl<T, F: FolderFilter<P> + FolderRecurseFilter<P> + FileFilter<P>, P: PathType + ?Sized> StructuralPartialEq for DirDescendants<T, F, P>

Auto Trait Implementations§

§

impl<T, F, P> Freeze for DirDescendants<T, F, P>
where P: ?Sized,

§

impl<T, F, P> RefUnwindSafe for DirDescendants<T, F, P>

§

impl<T, F, P> Send for DirDescendants<T, F, P>
where F: Send, T: Send, P: ?Sized,

§

impl<T, F, P> Sync for DirDescendants<T, F, P>
where F: Sync, T: Sync, P: ?Sized,

§

impl<T, F, P> Unpin for DirDescendants<T, F, P>
where F: Unpin, <P as PathType>::PathSegmentOwned: Unpin, <P as PathType>::OwnedPath: Unpin, T: Unpin, P: ?Sized,

§

impl<T, F, P> UnwindSafe for DirDescendants<T, F, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DirStructureItem for T

Source§

fn read(path: impl AsRef<<FsVfs as VfsCore>::Path>) -> VfsResult<Self, FsVfs>
where Self: ReadFrom<'static, FsVfs> + Sized,

Uses the ReadFrom implementation to read the structure from disk, from the specified path.
Source§

fn write<'a, 'vfs: 'a>( &'a self, path: impl AsRef<<FsVfs as VfsCore>::Path>, ) -> VfsResult<(), FsVfs>
where Self: WriteTo<'vfs, FsVfs>,

Uses the WriteTo implementation to write the structure to disk at the specified path.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<'data, I> IntoParallelRefMutIterator<'data> for I

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,