Trait fs_node::Directory

source ·
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§

source

fn get(&self, name: &str) -> Option<FileOrDir>

Gets either the file or directory in this Directory on its name.

source

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.

source

fn remove(&mut self, node: &FileOrDir) -> Option<FileOrDir>

Removes a file or directory from this directory and returns it if found. Also, the returned node’s parent directory reference is cleared.

The lock on node must not be held because it will be acquired within this function.

source

fn list(&self) -> Vec<String>

Lists the names of the nodes in this directory.

Provided Methods§

source

fn get_file(&self, name: &str) -> Option<FileRef>

Like Directory::get(), but only looks for files matching the given name in this Directory.

source

fn get_dir(&self, name: &str) -> Option<DirRef>

Like Directory::get(), but only looks for directories matching the given name in this Directory.

Implementors§