pub struct EvalCtx<'a> {
pub note: &'a Note,
pub corpus: &'a Corpus,
pub this: Option<&'a Note>,
pub formulas: &'a BTreeMap<String, Expr>,
/* private fields */
}Expand description
Everything an expression needs to evaluate: the note it’s evaluated against,
the whole corpus (for backlinks/link resolution), the base’s formula
definitions, and an optional this context note (the note a base is embedded
in). Formula evaluation is memoized per note with a cycle guard.
Fields§
§note: &'a Note§corpus: &'a Corpus§this: Option<&'a Note>§formulas: &'a BTreeMap<String, Expr>Formula name → parsed expression (shared across the whole base).
Implementations§
Source§impl<'a> EvalCtx<'a>
impl<'a> EvalCtx<'a>
pub fn new( note: &'a Note, corpus: &'a Corpus, formulas: &'a BTreeMap<String, Expr>, ) -> Self
pub fn with_this(self, this: Option<&'a Note>) -> Self
Sourcepub fn eval_formula(&self, name: &str) -> Value
pub fn eval_formula(&self, name: &str) -> Value
Evaluate a named formula against this context’s note, memoized, with a
cycle guard (a self-referential formula yields Null).
Sourcepub fn eval(&self, expr: &Expr) -> Value
pub fn eval(&self, expr: &Expr) -> Value
Evaluate an expression to a value. Depth-guarded: a pathologically deep AST
resolves to Null past MAX_EVAL_DEPTH rather than overflowing the stack.
Auto Trait Implementations§
impl<'a> !Freeze for EvalCtx<'a>
impl<'a> !RefUnwindSafe for EvalCtx<'a>
impl<'a> !Sync for EvalCtx<'a>
impl<'a> Send for EvalCtx<'a>
impl<'a> Unpin for EvalCtx<'a>
impl<'a> UnsafeUnpin for EvalCtx<'a>
impl<'a> UnwindSafe for EvalCtx<'a>
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
Mutably borrows from an owned value. Read more