Crate fs_node

source ·
Expand description

Defines traits for Files and Directories within the virtual filesystem. These files and directories mimic that of a standard unix virtual filesystem, where directories follow a hierarchical system and all directories have a parent directory (except for the special root directory). All files must be contained within directories.

Note that both File and Directory extend from FsNode, which is a trait that defines common methods for both Files and Directories to enhance code reuse

Some functions return an enum FileOrDir; this allows us to seamlessly call functions on the return types of other filesystem functions, and then we simply match on the FSnode to extract the concrete type to perform the desired function

Enums

  • Allows us to return a generic type that can be matched by the caller to extract the underlying type

Traits

  • Trait for directories, implementors of Directory must also implement FsNode
  • A trait that covers any filesystem node, both files and directories.

Type Aliases

  • A reference to any type that implements the Directory trait, which can only represent a Directory (not a File).
  • A reference to any type that implements the File trait, which can only represent a File (not a Directory).
  • A weak reference to any type that implements the Directory trait, which can only represent a Directory (not a File).
  • A weak reference to any type that implements the File trait, which can only represent a File (not a Directory).