pub struct EvaluationBuilder<'co, 'ro, 'env, IO> {
    pub(crate) source_map: Option<SourceCode>,
    pub(crate) globals: BuilderGlobals,
    pub(crate) env: Option<&'env HashMap<SmolStr, Value>>,
    pub(crate) io_handle: IO,
    pub(crate) enable_import: bool,
    pub(crate) strict: bool,
    pub(crate) nix_path: Option<String>,
    pub(crate) compiler_observer: Option<&'co mut dyn CompilerObserver>,
    pub(crate) runtime_observer: Option<&'ro mut dyn RuntimeObserver>,
}
Expand description

Builder for building an Evaluation.

Construct an EvaluationBuilder by calling one of:

Then configure the fields by calling the various methods on EvaluationBuilder, and finally call build to construct an Evaluation

Fields§

§source_map: Option<SourceCode>§globals: BuilderGlobals§env: Option<&'env HashMap<SmolStr, Value>>§io_handle: IO§enable_import: bool§strict: bool§nix_path: Option<String>§compiler_observer: Option<&'co mut dyn CompilerObserver>§runtime_observer: Option<&'ro mut dyn RuntimeObserver>

Implementations§

source§

impl<'co, 'ro, 'env, IO> EvaluationBuilder<'co, 'ro, 'env, IO>
where IO: AsRef<dyn EvalIO> + 'static,

source

pub fn build(self) -> Evaluation<'co, 'ro, 'env, IO>

Build an Evaluation based on the configuration in this builder.

This:

  • Adds a "storeDir" builtin containing the store directory of the configured IO handle
  • Sets up globals based on the configured builtins
  • Copies all other configured fields to the Evaluation
source§

impl<'co, 'ro, 'env, IO> EvaluationBuilder<'co, 'ro, 'env, IO>

source

pub fn new(io_handle: IO) -> Self

source

pub fn io_handle<IO2>( self, io_handle: IO2 ) -> EvaluationBuilder<'co, 'ro, 'env, IO2>

source

pub fn with_enable_import(self, enable_import: bool) -> Self

source

pub fn disable_import(self) -> Self

source

pub fn enable_import(self) -> Self

source

pub(crate) fn builtins_mut(&mut self) -> &mut BuilderBuiltins

source

pub fn add_builtins<I>(self, builtins: I) -> Self
where I: IntoIterator<Item = (&'static str, Value)>,

Add additional builtins (represented as tuples of name and Value) to this evaluation builder.

§Panics

Panics if this evaluation builder has had globals set via [with_globals]

source

pub fn add_src_builtin(self, name: &'static str, src: &'static str) -> Self

Add additional builtins that are implemented in Nix source code (represented as tuples of name and nix source) to this evaluation builder.

§Panics

Panics if this evaluation builder has had globals set via [with_globals]

source

pub fn with_globals(self, globals: Rc<GlobalsMap>) -> Self

Set the globals for this evaluation builder to a previously-constructed globals map. Intended to allow sharing globals across multiple evaluations (eg for the REPL).

Discards any builtins previously configured via [add_builtins] and [add_src_builtins]. If either of those methods is called on the evaluation builder after this one, they will panic.

source

pub fn with_source_map(self, source_map: SourceCode) -> Self

source

pub fn with_strict(self, strict: bool) -> Self

source

pub fn strict(self) -> Self

source

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

source

pub fn env(self, env: Option<&'env HashMap<SmolStr, Value>>) -> Self

source

pub fn compiler_observer( self, compiler_observer: Option<&'co mut dyn CompilerObserver> ) -> Self

source

pub fn set_compiler_observer( &mut self, compiler_observer: Option<&'co mut dyn CompilerObserver> )

source

pub fn runtime_observer( self, runtime_observer: Option<&'ro mut dyn RuntimeObserver> ) -> Self

source

pub fn set_runtime_observer( &mut self, runtime_observer: Option<&'ro mut dyn RuntimeObserver> )

source§

impl<'co, 'ro, 'env, IO> EvaluationBuilder<'co, 'ro, 'env, IO>

source

pub fn source_map(&mut self) -> &SourceCode

source§

impl<'co, 'ro, 'env> EvaluationBuilder<'co, 'ro, 'env, Box<dyn EvalIO>>

source

pub fn new_pure() -> Self

Initialize an Evaluation, without the import statement available, and all IO operations stubbed out.

source

pub fn enable_impure(self, io: Option<Box<dyn EvalIO>>) -> Self

Configure an Evaluation to have impure features available with the given I/O implementation.

If no I/O implementation is supplied, StdIO is used by default.

source

pub fn new_impure() -> Self

Initialise an Evaluation, with all impure features turned on by default.

Auto Trait Implementations§

§

impl<'co, 'ro, 'env, IO> Freeze for EvaluationBuilder<'co, 'ro, 'env, IO>
where IO: Freeze,

§

impl<'co, 'ro, 'env, IO> !RefUnwindSafe for EvaluationBuilder<'co, 'ro, 'env, IO>

§

impl<'co, 'ro, 'env, IO> !Send for EvaluationBuilder<'co, 'ro, 'env, IO>

§

impl<'co, 'ro, 'env, IO> !Sync for EvaluationBuilder<'co, 'ro, 'env, IO>

§

impl<'co, 'ro, 'env, IO> Unpin for EvaluationBuilder<'co, 'ro, 'env, IO>
where IO: Unpin,

§

impl<'co, 'ro, 'env, IO> !UnwindSafe for EvaluationBuilder<'co, 'ro, 'env, IO>

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, 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> Same for T

§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V