Struct rusty_nodejs_repl::ConfigBuilder

source ·
pub struct ConfigBuilder { /* private fields */ }
Expand description

Builder for Config.

Implementations§

source§

impl ConfigBuilder

source

pub fn imports(self, value: Vec<String>) -> Self

JS imports

source

pub fn before(self, value: Vec<String>) -> Self

code that runs before the REPL in an async context. setup, etc

source

pub fn repl_code(self, value: String) -> Self

define and run the REPL

source

pub fn after(self, value: Vec<String>) -> Self

code that runs after the REPL. teardown, etc run in revers order

source

pub fn script_file_name(self, value: String) -> Self

the name of the file within which the REPL is run

source

pub fn build_command( self, value: Option<Box<dyn Fn(&Config, &str, &str) -> String>>, ) -> Self

A function that constructs the shell script which runs the REPL. It is passed the config, the directory the REPL is run from, and the full path to the script_file_name file. Result looks like: NODE_PATH=../node_modules /path/to/nodejs_binary /path/to/tmp/repl_script.js.

source

pub fn copy_dirs(self, value: Vec<String>) -> Self

A list paths that will be copied into the tempfile::TempDir alongside the REPL script. Useful for importing custom code.

source

pub fn path_to_node_modules(self, value: Option<String>) -> Self

path to a node_modules directory which node will use

source

pub fn node_binary(self, value: String) -> Self

path to node binary

source

pub fn eof(self, value: Vec<u8>) -> Self

source

pub fn build(self) -> Result<Config, ConfigBuilderError>

Builds a new Config.

§Errors

If a required field has not been initialized.

Trait Implementations§

source§

impl Default for ConfigBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more