Struct dir_structure::DirChildren
source · pub struct DirChildren<T>where
T: DirStructureItem,{
pub self_path: PathBuf,
pub children: Vec<DirChild<T>>,
}Expand description
A directory structure where we don’t know the names of the folders at compile-time, and as such we cannot use the derive macro.
Instead we know that all the entries in the directory are folders,
and that they all have the same structure inside (defined by the [T] type parameter),
or they are all files (which can be read with DirChildren<String> for example).
In either case, [<T as ReadFrom>::read_from] must be able to read all the entries in
the directory.
The WriteTo implementation will directly write the children to the directory it
is passed, with no regards to the path stored in self_path.
Fields§
§self_path: PathBufThe path to the root directory.
This path doesn’t influence writing in any way, it is only to point out the directory after it has been read and parsed.
children: Vec<DirChild<T>>The children of the root directory.
Implementations§
source§impl<T> DirChildren<T>where
T: DirStructureItem,
impl<T> DirChildren<T>where T: DirStructureItem,
sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty DirChildren, with no children.
sourcepub fn with_children_from_iter(
self_path: impl Into<PathBuf>,
children: impl IntoIterator<Item = DirChild<T>>
) -> Self
pub fn with_children_from_iter( self_path: impl Into<PathBuf>, children: impl IntoIterator<Item = DirChild<T>> ) -> Self
Creates a DirChildren with the given path and children.
sourcepub fn get_name(&self, name: impl AsRef<OsStr>) -> Option<&DirChild<T>>
pub fn get_name(&self, name: impl AsRef<OsStr>) -> Option<&DirChild<T>>
Gets the child with the specified “file” name (last segment of path).
sourcepub fn iter(&self) -> DirChildrenIter<'_, T> ⓘ
pub fn iter(&self) -> DirChildrenIter<'_, T> ⓘ
Returns an iterator over the children.