pub trait Fs: Debug {
// Required methods
fn is_dir(&self, path: &Path) -> bool;
fn is_file(&self, path: &Path) -> bool;
fn read(&self, path: &Path) -> Result<Vec<u8, Global>, Error>;
}
Expand description
A trait to allow replacing the file system lookup mechanisms.
As it stands, this is imperfect: it’s still using the types and some operations from
std::path
, which constrain it to the target platform’s norms. This could be ameliorated by
the use of associated types for Path
and PathBuf
, and putting all remaining methods on this
trait (is_absolute
, parent
, join
, &c.); but that would infect too many other APIs to be
desirable, so we live with it as it is—which is also acceptable, because the motivating example
use case is mostly using this as an optimisation over the real platform underneath.
Required Methods§
sourcefn is_dir(&self, path: &Path) -> bool
fn is_dir(&self, path: &Path) -> bool
Returns true
if the path exists on disk and is pointing at a directory.