pub struct FoldOptions<'a> {Show 13 fields
pub op: IndexMap<String, Option<OpDef>>,
pub evaluate: FoldEvaluate<'a>,
pub inherit: Option<Inherit<'a>>,
pub recognise: Option<Recognise<'a>>,
pub k: Value,
pub doc: String,
pub load: Option<Load<'a>>,
pub cycle: FoldCycle,
pub tokens: bool,
pub positions: Option<Positions<'a>>,
pub max_depth: usize,
pub max_stack: usize,
pub report: Option<Box<dyn Fn(FoldReport) + 'a>>,
}Expand description
The options of one fold. Only evaluate is required; build with
FoldOptions::new and the with_ methods.
The callbacks are plain closures that may borrow from the caller’s
scope, for the life 'a of the options: a fold runs to completion
inside the call.
Fields§
§op: IndexMap<String, Option<OpDef>>The operator table; only its key operators matter to a fold. The same table the plugin was given can be passed as it is.
evaluate: FoldEvaluate<'a>§inherit: Option<Inherit<'a>>§recognise: Option<Recognise<'a>>§k: ValueThe starting bag of every document’s root. An empty map by default.
doc: StringThe key of the document being folded. Empty by default.
load: Option<Load<'a>>§cycle: FoldCycle§tokens: boolReduce token operator nodes met in the walk through evaluate
too, so one fold handles + and $ref. On by default. A token
operator is recognised only on a LIVE expression node, inside
crate::parse_scope: see fold.
positions: Option<Positions<'a>>§max_depth: usizeHow deep the walk may go, nesting and reference hops counted together. 1000 by default.
max_stack: usizeHow much stack, in bytes, the fold may use, measured from the
outermost fold running on the thread: FOLD_MAX_STACK, a
megabyte, by default. Past it the fold fails with FOLD_DEPTH
rather than overflow the stack, which would end the process. A
level of nesting costs no stack, since the walk over containers is
iterative; each reference hop does, since it re-enters the fold
through the resolver. Raise it only on a thread known to have more
than twice as much stack.
report: Option<Box<dyn Fn(FoldReport) + 'a>>Called once with the report when the fold succeeds.
Implementations§
Source§impl<'a> FoldOptions<'a>
impl<'a> FoldOptions<'a>
Sourcepub fn new(
evaluate: impl Fn(&Site<'_>, &Op, &[Value]) -> Result<Value, TabnasError> + 'a,
) -> Self
pub fn new( evaluate: impl Fn(&Site<'_>, &Op, &[Value]) -> Result<Value, TabnasError> + 'a, ) -> Self
Options with the given resolver and every default.
Sourcepub fn with_op(self, name: impl Into<String>, def: OpDef) -> Self
pub fn with_op(self, name: impl Into<String>, def: OpDef) -> Self
Add or replace one operator definition.
Sourcepub fn with_ops(self, op: IndexMap<String, Option<OpDef>>) -> Self
pub fn with_ops(self, op: IndexMap<String, Option<OpDef>>) -> Self
Use a whole operator table, such as the one an ExprOptions
carries.