pub struct EvaluationBuilder<'co, 'ro, 'env> {
pub(crate) source_map: Option<SourceCode>,
pub(crate) globals: BuilderGlobals,
pub(crate) env: Option<&'env FxHashMap<SmolStr, Value>>,
pub(crate) io_handle: Rc<dyn EvalIO>,
pub(crate) enable_import: bool,
pub(crate) mode: EvalMode,
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::newEvaluation::builder_impureEvaluationBuilder::new_impureEvaluation::builder_pureEvaluationBuilder::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: Rc<dyn EvalIO>§enable_import: bool§mode: EvalMode§nix_path: Option<String>§compiler_observer: Option<&'co mut dyn CompilerObserver>§runtime_observer: Option<&'ro mut dyn RuntimeObserver>Implementations§
Source§impl<'co, 'ro, 'env> EvaluationBuilder<'co, 'ro, 'env>
impl<'co, 'ro, 'env> EvaluationBuilder<'co, 'ro, 'env>
Sourcepub fn build(self) -> Evaluation<'co, 'ro, 'env>
pub fn build(self) -> Evaluation<'co, 'ro, 'env>
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> EvaluationBuilder<'co, 'ro, 'env>
impl<'co, 'ro, 'env> EvaluationBuilder<'co, 'ro, 'env>
pub fn new(io_handle: Rc<dyn EvalIO>) -> Self
pub fn io_handle( self, io_handle: Rc<dyn EvalIO>, ) -> EvaluationBuilder<'co, 'ro, 'env>
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 mode(self, mode: EvalMode) -> 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 EvaluationBuilder<'_, '_, '_>
impl EvaluationBuilder<'_, '_, '_>
pub fn source_map(&mut self) -> &SourceCode
Source§impl EvaluationBuilder<'_, '_, '_>
impl EvaluationBuilder<'_, '_, '_>
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<Rc<dyn EvalIO>>) -> Self
pub fn enable_impure(self, io: Option<Rc<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.
Auto Trait Implementations§
impl<'co, 'ro, 'env> Freeze for EvaluationBuilder<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !RefUnwindSafe for EvaluationBuilder<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !Send for EvaluationBuilder<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !Sync for EvaluationBuilder<'co, 'ro, 'env>
impl<'co, 'ro, 'env> Unpin for EvaluationBuilder<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !UnwindSafe for EvaluationBuilder<'co, 'ro, 'env>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more