pub struct EvaluationContext<'ctx, 'hook, N: Node<'ctx>> {
pub node: N,
pub position: usize,
pub size: usize,
pub variables: Option<&'hook (dyn Fn(&QName) -> Option<Value<N>> + 'hook)>,
pub namespaces: Option<&'hook (dyn Fn(&str) -> Option<String> + 'hook)>,
/* private fields */
}Expand description
The context an Expr is evaluated against (§2.2/§2.4): the context node,
its 1-based proximity position and the context size within whatever
node-set it was drawn from, a variable-binding lookup hook, and a
namespace-prefix resolution hook.
None in variables means “no variables are bound” — every
PrimaryExpr::Variable lookup then fails with EvalError::UnboundVariable.
Nothing in this phase binds variables yet (that is a schematron-engine
<let> concern), but PrimaryExpr::Variable still needs this real,
clearly-erroring path rather than a panic or a silently-wrong default.
None in namespaces means “no namespace bindings are declared” —
prefixed name tests then never match any node (see resolve_prefix’s
doc comment for the full rationale).
'ctx is the node/document borrow lifetime (N: Node<'ctx>); 'hook is
an independent lifetime for the variables/namespaces hook references.
The two are deliberately decoupled (see plan/05b-decouple-hook-lifetime.md):
a hook built locally within a single evaluate() call (e.g. a closure
over a temporary namespace-binding table) does not need to live as long
as the document itself, and there is no 'hook: 'ctx (or reverse) bound
between them — nothing here ever stores the hook and the node together
in a way that would require one.
_ctx is a zero-sized marker: 'ctx is only used in the N: Node<'ctx>
bound above, not in any field type on its own, and Rust requires every
declared lifetime parameter of a struct to appear in a field (E0392
otherwise) — this PhantomData satisfies that without adding any real
state.
Fields§
§node: N§position: usize§size: usize§variables: Option<&'hook (dyn Fn(&QName) -> Option<Value<N>> + 'hook)>§namespaces: Option<&'hook (dyn Fn(&str) -> Option<String> + 'hook)>Implementations§
Trait Implementations§
Source§impl<'ctx, 'hook, N: Clone + Node<'ctx>> Clone for EvaluationContext<'ctx, 'hook, N>
impl<'ctx, 'hook, N: Clone + Node<'ctx>> Clone for EvaluationContext<'ctx, 'hook, N>
Source§fn clone(&self) -> EvaluationContext<'ctx, 'hook, N>
fn clone(&self) -> EvaluationContext<'ctx, 'hook, N>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more