FileSystem

Trait FileSystem 

Source
pub trait FileSystem: Send + Sync {
    // Required methods
    fn new(yarn_pnp: bool) -> Self;
    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>;

    // Provided method
    fn read_to_string_bypass_system_cache(&self, path: &Path) -> Result<String> { ... }
}
Expand description

File System abstraction used for ResolverGeneric

Required Methods§

Source

fn new(yarn_pnp: bool) -> Self

Source

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

See std::fs::read_to_string

§Errors
§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.

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

Provided Methods§

Source

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

Reads a file while bypassing the system cache.

This is useful in scenarios where the file content is already cached in memory and you want to avoid the overhead of using the system cache.

§Errors

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§