pub struct Native { /* private fields */ }
Implementations§
Source§impl Native
impl Native
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new native virtual file system.
This file system grants access to the host file system.
Sourcepub fn resolve_file(&self, path: &Path) -> Option<PathBuf>
pub fn resolve_file(&self, path: &Path) -> Option<PathBuf>
Check whether path
points to a file in the virtual file system and
return the absolute path if it exists.
This API is infallible and will return None
for non-existent paths.
Sourcepub fn is_file(&self, path: &Path) -> bool
pub fn is_file(&self, path: &Path) -> bool
Check whether path
points to a file in the virtual file system.
This API is infallible and will return false
for non-existent paths.
Sourcepub fn read_file(&self, path: &Path) -> Result<Vec<u8>>
pub fn read_file(&self, path: &Path) -> Result<Vec<u8>>
Read file contents for the file at path
.
Returns a byte slice of complete file contents. If path
is relative,
it is absolutized relative to the current working directory of the
virtual file system.
§Errors
If path
does not exist, an io::Error
with error kind
io::ErrorKind::NotFound
is returned.
Sourcepub fn is_required(&self, path: &Path) -> Option<bool>
pub fn is_required(&self, path: &Path) -> Option<bool>
Check whether a file at path
has been required already.
This API is infallible and will return false
for non-existent paths.
Sourcepub fn mark_required(&mut self, path: &Path) -> Result<()>
pub fn mark_required(&mut self, path: &Path) -> Result<()>
Mark a source at path
as required on the interpreter.
This metadata is used by Kernel#require
and friends to enforce that
Ruby sources are only loaded into the interpreter once to limit side
effects.
§Errors
If path
does not exist, an io::Error
with error kind
io::ErrorKind::NotFound
is returned.