pub struct FoldBudget<'a> {
pub steps: usize,
pub check_every_n: usize,
pub on_check: Option<Box<dyn Fn(usize) -> bool + 'a>>,
}Expand description
A bound on a fold’s work, and a way to stop it.
One step is one container the fold starts to fold (a map, a list or an
operator node; a location already folded costs nothing), or one call a
resolver makes to Site::at, Site::written or Site::locate,
whatever it finds. Nothing else is a step: not Site::plain, not
inherit, not evaluate, not loading a document. One count spans
every document a fold loads.
Past steps the fold fails with FOLD_BUDGET. With check_every_n
and on_check both set, on_check is called at every Nth step with
the number taken so far, and a false return fails the fold with
FOLD_CANCEL: a host keeps a deadline there, or reads a flag another
thread sets. At one step the bound is tried before the check. Off by
default, as the engine’s own parse budget is.
Fields§
§steps: usizeThe most steps a fold may take; 0 sets no bound.
check_every_n: usizeCall on_check at every Nth step; 0 turns the check off.
on_check: Option<Box<dyn Fn(usize) -> bool + 'a>>Given the number of steps taken so far; false cancels the fold.