Skip to main content

VariableSolutionIndex

Trait VariableSolutionIndex 

Source
pub trait VariableSolutionIndex<S: Rdf> {
    // Required method
    fn index(self, solution: &QuerySolution<S>) -> Option<usize>;
}
Expand description

Trait for types that can index into a SPARQL query solution.

This trait abstracts over different ways to access variables in a QuerySolution. It allows the same lookup API to work with numeric indices, string variable names, or wrapped variable name types.

§Type Parameters

  • S - The RDF graph type implementing Rdf

Required Methods§

Source

fn index(self, solution: &QuerySolution<S>) -> Option<usize>

Returns the position index of a variable in the query solution.

This method attempts to locate the variable in the solution and returns its zero-based position index if found.

§Arguments
  • solution - The query solution to search within

Implementations on Foreign Types§

Source§

impl<S: Rdf> VariableSolutionIndex<S> for &str

Source§

fn index(self, solution: &QuerySolution<S>) -> Option<usize>

Finds the index of a variable by name string.

This implementation performs a linear search through the solution’s variables to find one matching the provided name string. The search compares against the bare variable name (without ? or $ prefix).

§Arguments
  • solution - The query solution to search
Source§

impl<S: Rdf> VariableSolutionIndex<S> for usize

Source§

fn index(self, _: &QuerySolution<S>) -> Option<usize>

Returns the numeric index directly without validation.

This implementation provides O(1) direct positional access to variables in a query solution. It does not validate that the index is within bounds; validation should be performed by the caller when accessing the value.

§Arguments
  • _ - The query solution (unused, as the index is already known)

Implementors§