Struct tvix_eval::EvaluationBuilder
source · pub struct EvaluationBuilder<'co, 'ro, 'env, IO> {
pub(crate) source_map: Option<SourceCode>,
pub(crate) globals: BuilderGlobals,
pub(crate) env: Option<&'env FxHashMap<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:
Evaluation::builder
/EvaluationBuilder::new
Evaluation::builder_impure
EvaluationBuilder::new_impure
Evaluation::builder_pure
EvaluationBuilder::new_pure
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 FxHashMap<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>
impl<'co, 'ro, 'env, IO> EvaluationBuilder<'co, 'ro, 'env, IO>
sourcepub fn build(self) -> Evaluation<'co, 'ro, 'env, IO>
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>
impl<'co, 'ro, 'env, IO> EvaluationBuilder<'co, 'ro, 'env, IO>
pub fn new(io_handle: IO) -> Self
pub fn io_handle<IO2>( self, io_handle: IO2 ) -> EvaluationBuilder<'co, 'ro, 'env, IO2>
pub fn with_enable_import(self, enable_import: bool) -> Self
pub fn disable_import(self) -> Self
pub fn enable_import(self) -> Self
pub(crate) fn builtins_mut(&mut self) -> &mut BuilderBuiltins
sourcepub fn add_builtins<I>(self, builtins: I) -> Self
pub fn add_builtins<I>(self, builtins: I) -> Self
sourcepub fn add_src_builtin(self, name: &'static str, src: &'static str) -> Self
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
]
sourcepub fn with_globals(self, globals: Rc<GlobalsMap>) -> Self
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.
pub fn with_source_map(self, source_map: SourceCode) -> Self
pub fn with_strict(self, strict: bool) -> Self
pub fn strict(self) -> Self
pub fn nix_path(self, nix_path: Option<String>) -> Self
pub fn env(self, env: Option<&'env FxHashMap<SmolStr, Value>>) -> Self
pub fn compiler_observer( self, compiler_observer: Option<&'co mut dyn CompilerObserver> ) -> Self
pub fn set_compiler_observer( &mut self, compiler_observer: Option<&'co mut dyn CompilerObserver> )
pub fn runtime_observer( self, runtime_observer: Option<&'ro mut dyn RuntimeObserver> ) -> Self
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>
impl<'co, 'ro, 'env, IO> EvaluationBuilder<'co, 'ro, 'env, IO>
pub fn source_map(&mut self) -> &SourceCode
source§impl<'co, 'ro, 'env> EvaluationBuilder<'co, 'ro, 'env, Box<dyn EvalIO>>
impl<'co, 'ro, 'env> EvaluationBuilder<'co, 'ro, 'env, Box<dyn EvalIO>>
sourcepub fn new_pure() -> Self
pub fn new_pure() -> Self
Initialize an Evaluation
, without the import statement available, and
all IO operations stubbed out.
sourcepub fn enable_impure(self, io: Option<Box<dyn EvalIO>>) -> Self
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.
sourcepub fn new_impure() -> Self
pub fn new_impure() -> Self
Initialise an Evaluation
, with all impure features turned on by default.