Skip to main content

EvaluationContext

Struct EvaluationContext 

Source
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§

Source§

impl<'ctx, 'hook, N: Node<'ctx>> EvaluationContext<'ctx, 'hook, N>

Source

pub fn new(node: N) -> Self

A context whose node is both the sole member and the first member of its own (size-1) context node-set, with no variable bindings and no namespace context.

Trait Implementations§

Source§

impl<'ctx, 'hook, N: Clone + Node<'ctx>> Clone for EvaluationContext<'ctx, 'hook, N>

Source§

fn clone(&self) -> EvaluationContext<'ctx, 'hook, N>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'ctx, 'hook, N: Copy + Node<'ctx>> Copy for EvaluationContext<'ctx, 'hook, N>

Auto Trait Implementations§

§

impl<'ctx, 'hook, N> !RefUnwindSafe for EvaluationContext<'ctx, 'hook, N>

§

impl<'ctx, 'hook, N> !Send for EvaluationContext<'ctx, 'hook, N>

§

impl<'ctx, 'hook, N> !Sync for EvaluationContext<'ctx, 'hook, N>

§

impl<'ctx, 'hook, N> !UnwindSafe for EvaluationContext<'ctx, 'hook, N>

§

impl<'ctx, 'hook, N> Freeze for EvaluationContext<'ctx, 'hook, N>
where N: Freeze,

§

impl<'ctx, 'hook, N> Unpin for EvaluationContext<'ctx, 'hook, N>
where N: Unpin,

§

impl<'ctx, 'hook, N> UnsafeUnpin for EvaluationContext<'ctx, 'hook, N>
where N: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.