pub struct InterpreterConfig { /* private fields */ }
Expand description
The convenient way to create rustpython_vm::Interpreter with stdlib and other stuffs.
Basic usage:
let interpreter = rustpython::InterpreterConfig::new()
.init_stdlib()
.interpreter();
To override rustpython_vm::Settings:
use rustpython_vm::Settings;
// Override your settings here.
let mut settings = Settings::default();
settings.debug = true;
// You may want to add paths to `rustpython_vm::Settings::path_list` to allow import python libraries.
settings.path_list.push("".to_owned()); // add current working directory
let interpreter = rustpython::InterpreterConfig::new()
.settings(settings)
.interpreter();
To add native modules:
ⓘ
let interpreter = rustpython::InterpreterConfig::new()
.init_stdlib()
.init_hook(Box::new(|vm| {
vm.add_native_module(
"your_module_name".to_owned(),
Box::new(your_module::make_module),
);
}))
.interpreter();
Implementations§
Source§impl InterpreterConfig
impl InterpreterConfig
pub fn new() -> Self
pub fn interpreter(self) -> Interpreter
pub fn settings(self, settings: Settings) -> Self
pub fn init_hook(self, hook: Box<dyn FnOnce(&mut VirtualMachine)>) -> Self
pub fn add_native_module( self, name: String, make_module: fn(&VirtualMachine) -> PyRef<PyModule>, ) -> Self
pub fn init_stdlib(self) -> Self
Trait Implementations§
Source§impl Default for InterpreterConfig
impl Default for InterpreterConfig
Source§fn default() -> InterpreterConfig
fn default() -> InterpreterConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InterpreterConfig
impl !RefUnwindSafe for InterpreterConfig
impl !Send for InterpreterConfig
impl !Sync for InterpreterConfig
impl Unpin for InterpreterConfig
impl !UnwindSafe for InterpreterConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more