///|
/// Explicit resource budgets consumed by the expression compiler.
declare pub type CompileLimits

///|
/// Construct validated compiler budgets.
declare pub fn CompileLimits::new(
  max_source_units : Int,
  max_tokens : Int,
  max_nesting : Int,
) -> CompileLimits raise @diagnostic.XPathError

///|
/// Conservative library defaults documented by the implementation.
declare pub fn CompileLimits::safe_defaults() -> CompileLimits

///|
declare pub fn CompileLimits::max_source_units(self : CompileLimits) -> Int

///|
declare pub fn CompileLimits::max_tokens(self : CompileLimits) -> Int

///|
declare pub fn CompileLimits::max_nesting(self : CompileLimits) -> Int

///|
/// Namespace bindings and compile-time resource limits used by the compiler.
declare pub type StaticContext

///|
/// Create the default XPath 1.0 static context, including the `xml` prefix.
declare pub fn StaticContext::new() -> StaticContext

///|
/// Return a new context with one prefix binding.
///
/// The prefix must be non-empty; `xmlns` is forbidden and `xml` can only map
/// to its standard URI. Rebinding another prefix replaces its old binding in
/// the returned snapshot. Unprefixed XPath name tests always use the null
/// namespace rather than any XML default namespace.
declare pub fn StaticContext::with_namespace(
  self : StaticContext,
  prefix : String,
  uri : String,
) -> StaticContext raise @diagnostic.XPathError

///|
/// Return a new context with explicit validated compiler budgets.
declare pub fn StaticContext::with_limits(
  self : StaticContext,
  limits : CompileLimits,
) -> StaticContext

///|
declare pub fn StaticContext::limits(self : StaticContext) -> CompileLimits

///|
/// Resolve a prefix without silently treating unknown prefixes as empty.
declare pub fn StaticContext::resolve_prefix(
  self : StaticContext,
  prefix : String,
) -> String?

///|
/// Explicit resource budgets consumed by one evaluation.
declare pub type EvaluationLimits

///|
/// Construct validated evaluator budgets.
declare pub fn EvaluationLimits::new(
  max_steps : Int,
  max_nodeset_size : Int,
) -> EvaluationLimits raise @diagnostic.XPathError

///|
/// Conservative library defaults documented by the implementation.
declare pub fn EvaluationLimits::safe_defaults() -> EvaluationLimits

///|
declare pub fn EvaluationLimits::max_steps(self : EvaluationLimits) -> Int

///|
declare pub fn EvaluationLimits::max_nodeset_size(
  self : EvaluationLimits,
) -> Int

///|
/// Runtime document, context node, position/size, variables and budgets.
declare pub type DynamicContext

///|
/// Create a top-level dynamic context at position 1 of size 1.
declare pub fn DynamicContext::new(
  document : @model.Document,
  context_node : @model.NodeId,
) -> DynamicContext raise @diagnostic.XPathError

///|
/// Return a new context with one variable binding.
///
/// P0 node-sets are single-document. A node-set variable owned by another
/// document is rejected instead of inventing a cross-document order.
declare pub fn DynamicContext::with_variable(
  self : DynamicContext,
  name : @model.QName,
  value : @value.XPathValue,
) -> DynamicContext raise @diagnostic.XPathError

///|
/// Resolve a variable expanded name without inventing an empty binding.
declare pub fn DynamicContext::resolve_variable(
  self : DynamicContext,
  name : @model.QName,
) -> @value.XPathValue?

///|
/// Derive the focus used while evaluating one predicate candidate.
///
/// The node must belong to the same document and
/// `1 <= position <= size`.
declare pub fn DynamicContext::with_focus(
  self : DynamicContext,
  context_node : @model.NodeId,
  position : Int,
  size : Int,
) -> DynamicContext raise @diagnostic.XPathError

///|
/// Return a new context with explicit validated evaluation budgets.
declare pub fn DynamicContext::with_limits(
  self : DynamicContext,
  limits : EvaluationLimits,
) -> DynamicContext

///|
declare pub fn DynamicContext::limits(self : DynamicContext) -> EvaluationLimits

///|
/// Document being evaluated.
declare pub fn DynamicContext::document(
  self : DynamicContext,
) -> @model.Document

///|
/// Current context node.
declare pub fn DynamicContext::context_node(
  self : DynamicContext,
) -> @model.NodeId

///|
/// One-based context position.
declare pub fn DynamicContext::position(self : DynamicContext) -> Int

///|
/// Context size.
declare pub fn DynamicContext::size(self : DynamicContext) -> Int