[−][src]Trait artichoke_backend::extn::prelude::LoadSources
Load Ruby sources and Rust extensions into an interpreter.
Associated Types
type Artichoke
[src]
Concrete type for interpreter.
type Error
[src]
Concrete type for errors returned from filesystem IO.
type Exception
[src]
Concrete type for errors returned by File::require
.
Required methods
pub fn def_file_for_type<P, T>(&mut self, path: P) -> Result<(), Self::Error> where
T: File<Artichoke = Self::Artichoke, Error = Self::Exception>,
P: AsRef<Path>,
[src]
T: File<Artichoke = Self::Artichoke, Error = Self::Exception>,
P: AsRef<Path>,
Add a Rust extension hook to the virtual filesystem. A stub Ruby file is
added to the filesystem and File::require
will dynamically define
Ruby items when invoked via Kernel#require
.
If path
is a relative path, the Ruby source is added to the
filesystem relative to RUBY_LOAD_PATH
. If the path is absolute, the
file is placed directly on the filesystem. Anscestor directories are
created automatically.
Errors
If the underlying filesystem is inaccessible, an error is returned.
If writes to the underlying filesystem fail, an error is returned.
pub fn def_rb_source_file<P, T>(
&mut self,
path: P,
contents: T
) -> Result<(), Self::Error> where
T: Into<Cow<'static, [u8]>>,
P: AsRef<Path>,
[src]
&mut self,
path: P,
contents: T
) -> Result<(), Self::Error> where
T: Into<Cow<'static, [u8]>>,
P: AsRef<Path>,
Add a Ruby source to the virtual filesystem.
If path
is a relative path, the Ruby source is added to the
filesystem relative to RUBY_LOAD_PATH
. If the path is absolute, the
file is placed directly on the filesystem. Anscestor directories are
created automatically.
Errors
If the underlying filesystem is inaccessible, an error is returned.
If writes to the underlying filesystem fail, an error is returned.
pub fn source_is_file<P>(&self, path: P) -> Result<bool, Self::Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Test for a source file at a path.
Query the underlying virtual filesystem to check if path
points to a
source file.
This function returns false
if path
does not exist in the virtual
filesystem.
Errors
If the underlying filesystem is inaccessible, an error is returned.
pub fn load_source<P>(&mut self, path: P) -> Result<bool, Self::Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Load source located at the given path.
Query the underlying virtual filesystem for a source file and load it onto the interpreter. This loads files with the following steps:
- Retrieve and execute the extension hook, if any.
- Read file contents and
eval
them.
If this function returns without error, the feature specified by path
is loaded, but is not added to $LOADED_FEATURES
. This function is
equivalent to Kernel#load
.
Errors
If the underlying filesystem is inaccessible, an error is returned.
If reads to the underlying filesystem fail, an error is returned.
If path
does not point to a source file, an error is returned.
If the souce file at path
has no contents, an error is returned.
pub fn require_source<P>(&mut self, path: P) -> Result<bool, Self::Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
Require source located at the given path.
Query the underlying virtual filesystem for a source file and require it onto the interpreter. This requires files with the following steps:
- Retrieve and execute the extension hook, if any.
- Read file contents and
eval
them. - Mark file as required and add to
$LOADED_FEATURES
.
If this function returns without error, the feature specified by path
is loaded and added to $LOADED_FEATURES
. This function is equivalent
to Kernel#require
.
Errors
If the underlying filesystem is inaccessible, an error is returned.
If reads to the underlying filesystem fail, an error is returned.
If path
does not point to a source file, an error is returned.
If the souce file at path
has no contents, an error is returned.
pub fn read_source_file_contents<P>(
&self,
path: P
) -> Result<Cow<'_, [u8]>, Self::Error> where
P: AsRef<Path>,
[src]
&self,
path: P
) -> Result<Cow<'_, [u8]>, Self::Error> where
P: AsRef<Path>,
Retrieve file contents for a source file.
Query the underlying virtual filesystem for the file contents of the
source file at path
.
Errors
If the underlying filesystem is inaccessible, an error is returned.
If reads to the underlying filesystem fail, an error is returned.
If path
does not point to a source file, an error is returned.
Implementors
impl LoadSources for Artichoke
[src]
type Artichoke = Self
type Error = Error
type Exception = Error
fn def_file_for_type<P, T>(&mut self, path: P) -> Result<(), Self::Error> where
P: AsRef<Path>,
T: File<Artichoke = Self::Artichoke, Error = Self::Exception>,
[src]
P: AsRef<Path>,
T: File<Artichoke = Self::Artichoke, Error = Self::Exception>,
fn def_rb_source_file<P, T>(
&mut self,
path: P,
contents: T
) -> Result<(), Self::Error> where
P: AsRef<Path>,
T: Into<Cow<'static, [u8]>>,
[src]
&mut self,
path: P,
contents: T
) -> Result<(), Self::Error> where
P: AsRef<Path>,
T: Into<Cow<'static, [u8]>>,
fn source_is_file<P>(&self, path: P) -> Result<bool, Self::Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
fn load_source<P>(&mut self, path: P) -> Result<bool, Self::Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
fn require_source<P>(&mut self, path: P) -> Result<bool, Self::Error> where
P: AsRef<Path>,
[src]
P: AsRef<Path>,
fn read_source_file_contents<P>(
&self,
path: P
) -> Result<Cow<'_, [u8]>, Self::Error> where
P: AsRef<Path>,
[src]
&self,
path: P
) -> Result<Cow<'_, [u8]>, Self::Error> where
P: AsRef<Path>,