pub trait Directory: FsNode {
// Required methods
fn get(&self, name: &str) -> Option<FileOrDir>;
fn insert(
&mut self,
node: FileOrDir
) -> Result<Option<FileOrDir>, &'static str>;
fn remove(&mut self, node: &FileOrDir) -> Option<FileOrDir>;
fn list(&self) -> Vec<String>;
// Provided methods
fn get_file(&self, name: &str) -> Option<FileRef> { ... }
fn get_dir(&self, name: &str) -> Option<DirRef> { ... }
}
Expand description
Trait for directories, implementors of Directory must also implement FsNode
Required Methods§
sourcefn get(&self, name: &str) -> Option<FileOrDir>
fn get(&self, name: &str) -> Option<FileOrDir>
Gets either the file or directory in this Directory
on its name.
sourcefn insert(&mut self, node: FileOrDir) -> Result<Option<FileOrDir>, &'static str>
fn insert(&mut self, node: FileOrDir) -> Result<Option<FileOrDir>, &'static str>
Inserts the given new file or directory into this directory. If an existing node has the same name, that node is replaced and returned.
Note that this function does not set the given node
’s parent directory;
that should be set when the node
was originally created, before calling this function.
However, if a node is replaced, that old node’s parent directory will be cleared
to reflect that it is no longer in this directory.
The lock on node
must not be held because it will be acquired within this function.