artichoke_core::file

Trait File

Source
pub trait File {
    type Artichoke;
    type Error;

    // Required method
    fn require(interp: &mut Self::Artichoke) -> Result<(), Self::Error>;
}
Expand description

Rust extension hook that can be required.

Files are mounted in the interpreter file system and can modify interpreter state when they are loaded.

Required Associated Types§

Source

type Artichoke

Concrete type for interpreter.

Source

type Error

Concrete error type for eval functions.

Required Methods§

Source

fn require(interp: &mut Self::Artichoke) -> Result<(), Self::Error>

Called when the filename mapped to this type is required by the VM.

This function can mutate interpreter state, such as defining classes and modules. This function is equivalent to the “init” methods of C-implemented Rubygems.

§Errors

If a fallible API on the interpreter returns an error, implementors should return an error. Example fallible APIs that might be called on require include Eval::eval and LoadSources::def_rb_source_file.

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§