Crate artichoke_core[−][src]
This crate provides a set of traits that, when implemented, comprise a complete Ruby interpreter.
artichoke-core
is no_std
+ alloc
with an optional (enabled by default)
std
feature.
Interpreters implement the traits in Artichoke Core to indicate which capabilities they offer. Defining interpreters by their capabilities allows for interpreter agnostic implementations of Ruby Core and Standard Library.
Interpreter APIs
Artichoke Core defines traits for the following interpreter capabilities:
DefineConstant
: Define global, class, and module constants to be arbitrary RubyValue
s.Eval
: Execute Ruby source code on an interpreter from various sources.Globals
: Get, set, and unset interpreter-level global variables.Intern
: Intern bytestrings to a cheap to copy and compare symbol type.Io
: External I/O APIs, such as writing to the standard output of the current process.LoadSources
: Require source code from interpreter disk orFile
gems.Parser
: Manipulate the parser state, e.g. setting the current filename.Prng
: An interpreter-level pseudorandom number generator that is the backend forRandom::DEFAULT
.Regexp
: ManipulateRegexp
global state.ReleaseMetadata
: Enable interpreters to describe themselves.TopSelf
: Access to the root execution context.Warn
: Emit warnings.
Artichoke Core also describes what capabilities a Ruby
Value
must have and how to convert between Ruby VM and
Rust types.
Examples
artichoke-backend
is one implementation of the artichoke-core
traits.
To use all of the APIs defined in Artichoke Core, bring the traits into scope by importing the prelude:
use artichoke_core::prelude::*;
Crate features
All features are enabled by default:
- std: By default,
artichoke-core
isno_std
+alloc
. Enabling this feature adds several trait methods that depend onOsStr
andPath
as well as several implementations ofstd::error::Error
.
Modules
coerce_to_numeric | Coerce Ruby values to native numerics. |
constant | Define constants on an interpreter. |
convert | Convert between Rust and Ruby objects. |
debug | Routines for debugging and printing exception messages. |
eval | Run code on an Artichoke interpreter. |
file | File-backed Rust extensions for the Artichoke VM. |
globals | Get and set global variables on an interpreter. |
intern | Intern |
io | I/O read and write APIs. |
load | Load Ruby and Rust sources into the VM. |
parser | Parse code on an Artichoke interpreter. |
prelude | A “prelude” for users of the |
prng | Interpreter global psuedorandom number generator. |
regexp | Track |
release_metadata | Information about an Artichoke build. |
top_self | Expose the global context, called top self, to the interpreter. |
types | Ruby and Rust type mappings. |
value | Types that implement |
warn | Emit warnings during interpreter execution. |