pub trait ModuleFsReader {
// Required methods
fn canonical_guest_path(&mut self, guest_path: &str) -> Option<String>;
fn read_to_string(&mut self, guest_path: &str) -> Option<String>;
fn path_is_dir(&mut self, guest_path: &str) -> Option<bool>;
fn path_exists(&mut self, guest_path: &str) -> bool;
}Expand description
Read-only filesystem primitives the module resolver needs. The resolution
algorithm itself is pure path algebra over these four operations; pointing
it at a different backing store (host files vs. the kernel VFS) is purely a
matter of supplying a different ModuleFsReader.
All paths are guest paths (e.g. /root/node_modules/foo/index.js). Symlink
following is the reader’s responsibility: canonical_guest_path must return
the fully-resolved guest path (realpath), and path_is_dir/path_exists
must follow symlinks the way real Node’s fs.stat/fs.existsSync do.
Required Methods§
Sourcefn canonical_guest_path(&mut self, guest_path: &str) -> Option<String>
fn canonical_guest_path(&mut self, guest_path: &str) -> Option<String>
Realpath of guest_path, expressed as a guest path. None if the path
does not resolve (does not exist / escapes the addressable tree).
Sourcefn read_to_string(&mut self, guest_path: &str) -> Option<String>
fn read_to_string(&mut self, guest_path: &str) -> Option<String>
Read the file at guest_path as a UTF-8 string, following symlinks.
Sourcefn path_is_dir(&mut self, guest_path: &str) -> Option<bool>
fn path_is_dir(&mut self, guest_path: &str) -> Option<bool>
Some(true) if guest_path is a directory, Some(false) if it exists
but is not a directory, None if it does not exist. Follows symlinks.
Sourcefn path_exists(&mut self, guest_path: &str) -> bool
fn path_exists(&mut self, guest_path: &str) -> bool
Whether guest_path exists, following symlinks.
Trait Implementations§
Source§impl ModuleFsReader for &mut dyn ModuleFsReader
impl ModuleFsReader for &mut dyn ModuleFsReader
Source§fn canonical_guest_path(&mut self, guest_path: &str) -> Option<String>
fn canonical_guest_path(&mut self, guest_path: &str) -> Option<String>
guest_path, expressed as a guest path. None if the path
does not resolve (does not exist / escapes the addressable tree).Source§fn read_to_string(&mut self, guest_path: &str) -> Option<String>
fn read_to_string(&mut self, guest_path: &str) -> Option<String>
guest_path as a UTF-8 string, following symlinks.Source§fn path_is_dir(&mut self, guest_path: &str) -> Option<bool>
fn path_is_dir(&mut self, guest_path: &str) -> Option<bool>
Some(true) if guest_path is a directory, Some(false) if it exists
but is not a directory, None if it does not exist. Follows symlinks.Source§fn path_exists(&mut self, guest_path: &str) -> bool
fn path_exists(&mut self, guest_path: &str) -> bool
guest_path exists, following symlinks.Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".