FileSystem

Trait FileSystem 

Source
pub trait FileSystem: Send + Sync {
    // Required methods
    fn new(yarn_pnp: bool) -> Self;
    fn read(&self, path: &Path) -> Result<Vec<u8>>;
    fn read_to_string(&self, path: &Path) -> Result<String>;
    fn metadata(&self, path: &Path) -> Result<FileMetadata>;
    fn symlink_metadata(&self, path: &Path) -> Result<FileMetadata>;
    fn read_link(&self, path: &Path) -> Result<PathBuf, ResolveError>;
    fn canonicalize(&self, path: &Path) -> Result<PathBuf>;
}
Expand description

File System abstraction used for ResolverGeneric

Required Methods§

Source

fn new(yarn_pnp: bool) -> Self

Source

fn read(&self, path: &Path) -> Result<Vec<u8>>

Source

fn read_to_string(&self, path: &Path) -> Result<String>

Source

fn metadata(&self, path: &Path) -> Result<FileMetadata>

See std::fs::metadata

§Errors

See std::fs::metadata

§Warning

Use &Path instead of a generic P: AsRef<Path> here, because object safety requirements, it is especially useful, when you want to store multiple dyn FileSystem in a Vec or use a ResolverGeneric<Fs> in napi env.

See std::fs::symlink_metadata

§Errors

See std::fs::symlink_metadata

§Warning

Use &Path instead of a generic P: AsRef<Path> here, because object safety requirements, it is especially useful, when you want to store multiple dyn FileSystem in a Vec or use a ResolverGeneric<Fs> in napi env.

Returns the resolution of a symbolic link.

§Errors

See std::fs::read_link

Source

fn canonicalize(&self, path: &Path) -> Result<PathBuf>

Returns the canonical, absolute form of a path with all intermediate components normalized.

§Errors

See std::fs::canonicalize

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§