pub struct Config {
pub imports: Vec<String>,
pub before: Vec<String>,
pub repl_code: String,
pub after: Vec<String>,
pub copy_dirs: Vec<String>,
pub path_to_node_modules: Option<String>,
/* private fields */
}Expand description
Configurating for Repl. Usually you will want to setup the REPL context by importing some modules
and doing some setup. Then maybe, run some teardown code after the REPL closes.
Do this by giving JavaScript strings to Config::imports, Config::before, and Config::after fields.
The Node.js script will look something like:
// eval Config::imports
(async () => {
// eval Config::before
for await (const line of repl()) {
eval(line)
}
// eval Config::after
})()You will probably want to provide Config::path_to_node_modules so use can use npm
packages .
Fields§
§imports: Vec<String>JS imports
before: Vec<String>Code that runs before the REPL in an async context. setup, etc.
repl_code: StringDefine and run the REPL.
after: Vec<String>Code that runs after the REPL. teardown, etc. Run in reverse order.
copy_dirs: Vec<String>A list paths that will be copied into the tempfile::TempDir alongside the REPL script.
Useful for importing custom code.
path_to_node_modules: Option<String>Path to a node_modules directory which node will use.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl !RefUnwindSafe for Config
impl !Send for Config
impl !Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
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