pub struct Evaluation<'co, 'ro, 'env> {
pub(crate) source_map: SourceCode,
pub(crate) globals: Rc<GlobalsMap>,
pub(crate) env: Option<&'env FxHashMap<SmolStr, Value>>,
pub(crate) io_handle: Rc<dyn EvalIO>,
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
An Evaluation represents how a piece of Nix code is evaluated. It can be
instantiated and configured directly, or it can be accessed through the
various simplified helper methods available below.
Public fields are intended to be set by the caller. Setting all fields is optional.
Fields§
§source_map: SourceCodeSource code map used for error reporting.
globals: Rc<GlobalsMap>Set of all global values available at the top-level scope
env: Option<&'env FxHashMap<SmolStr, Value>>Top-level variables to define in the evaluation
io_handle: Rc<dyn EvalIO>Implementation of file-IO to use during evaluation, e.g. for impure builtins.
Defaults to DummyIO if not set explicitly.
mode: EvalModeSpecification for how to handle top-level values returned by evaluation
See the documentation for EvalMode for more information.
nix_path: Option<String>(optional) Nix search path, e.g. the value of NIX_PATH used
for resolving items on the search path (such as <nixpkgs>).
compiler_observer: Option<&'co mut dyn CompilerObserver>(optional) compiler observer for reporting on compilation details, like the emitted bytecode.
runtime_observer: Option<&'ro mut dyn RuntimeObserver>(optional) runtime observer, for reporting on execution steps of Nix code.
Implementations§
Source§impl<'co, 'ro, 'env> Evaluation<'co, 'ro, 'env>
impl<'co, 'ro, 'env> Evaluation<'co, 'ro, 'env>
Sourcepub fn builder(io_handle: Rc<dyn EvalIO>) -> EvaluationBuilder<'co, 'ro, 'env>
pub fn builder(io_handle: Rc<dyn EvalIO>) -> EvaluationBuilder<'co, 'ro, 'env>
Make a new builder for configuring an evaluation
Sourcepub fn globals(&self) -> Rc<GlobalsMap>
pub fn globals(&self) -> Rc<GlobalsMap>
Clone the reference to the map of Nix globals for this evaluation. If Values are shared
across subsequent Evaluations, it is important that those evaluations all have the same
underlying globals map.
Sourcepub fn source_map(&self) -> SourceCode
pub fn source_map(&self) -> SourceCode
Clone the reference to the contained source code map. This is used after an evaluation for
pretty error printing. Also, if Values are shared across subsequent Evaluations, it
is important that those evaluations all have the same underlying source code map.
Source§impl<'co, 'ro, 'env> Evaluation<'co, 'ro, 'env>
impl<'co, 'ro, 'env> Evaluation<'co, 'ro, 'env>
pub fn builder_impure() -> EvaluationBuilder<'co, 'ro, 'env>
pub fn builder_pure() -> EvaluationBuilder<'co, 'ro, 'env>
Source§impl Evaluation<'_, '_, '_>
impl Evaluation<'_, '_, '_>
Sourcepub fn compile_only(
self,
code: impl AsRef<str>,
location: Option<PathBuf>,
) -> EvaluationResult
pub fn compile_only( self, code: impl AsRef<str>, location: Option<PathBuf>, ) -> EvaluationResult
Only compile the provided source code, at an optional location of the source code (i.e. path to the file it was read from; used for error reporting, and for resolving relative paths in impure functions) This does not run the code, it only provides analysis (errors and warnings) of the compiler.
Auto Trait Implementations§
impl<'co, 'ro, 'env> Freeze for Evaluation<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !RefUnwindSafe for Evaluation<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !Send for Evaluation<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !Sync for Evaluation<'co, 'ro, 'env>
impl<'co, 'ro, 'env> Unpin for Evaluation<'co, 'ro, 'env>
impl<'co, 'ro, 'env> !UnwindSafe for Evaluation<'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