Skip to main content

QuerySolutions

Struct QuerySolutions 

Source
pub struct QuerySolutions<S: Rdf> { /* private fields */ }
Expand description

Represents a collection of query solutions from a SPARQL SELECT query.

This type holds the complete result set from a SPARQL query execution, including all solution rows and a prefix map for qualifying IRIs in output.

§Type Parameters

  • S - The RDF graph type implementing Rdf

Implementations§

Source§

impl<S: Rdf> QuerySolutions<S>

Source

pub fn new( solutions: Vec<QuerySolution<S>>, prefixmap: PrefixMap, ) -> QuerySolutions<S>

Creates a new query solutions collection with the given data.

§Arguments
  • solutions - Vector of query solution rows
  • prefixmap - Prefix map for IRI qualification in output
Source

pub fn empty() -> QuerySolutions<S>

Creates an empty query solutions collection.

Returns a new instance with no solutions and an empty prefix map.

Source

pub fn prefixmap(&self) -> &PrefixMap

Returns a reference to the prefix map.

The prefix map contains namespace bindings used for qualifying IRIs when displaying or formatting results.

Source

pub fn extend( &mut self, solutions: Vec<QuerySolution<S>>, prefixmap: PrefixMap, ) -> Result<(), PrefixMapError>

Extends this collection with additional solutions and prefix mappings.

§Arguments
  • solutions - Additional solutions to append
  • prefixmap - Prefix map to merge (new prefixes or updated IRIs)
§Errors

Returns an error if the prefix maps have conflicting definitions for the same prefix (same prefix bound to different namespaces).

Source

pub fn iter(&self) -> impl Iterator<Item = &QuerySolution<S>>

Returns an iterator over the query solutions.

Source

pub fn count(&self) -> usize

Returns the number of solutions in this collection.

Source

pub fn write_table(&self, writer: &mut dyn Write) -> Result<(), RDFError>

Writes the query solutions as a formatted ASCII table.

Produces a human-readable table with modern rounded borders, row numbers, and qualified IRIs using the prefix map. The table includes:

  • Row numbers in the first column (1-indexed)
  • Variable names as column headers (with ? prefix)
  • Qualified IRIs using registered prefixes
  • Blank nodes displayed as _:identifier
  • Literals shown with their datatype/language tags
  • RDF-star quoted triples in << s p o >> syntax
  • Empty cells for unbound variables
§Arguments
  • writer - Output destination (stdout, file, buffer, etc.)

Returns an error if:

  • Writing to the output fails
  • Term conversion fails when processing solutions
Source§

impl<S: Rdf + Serialize> QuerySolutions<S>

Source

pub fn as_json(&self) -> String

Serializes the query solutions as pretty-printed JSON.

Trait Implementations§

Source§

impl<S: Clone + Rdf> Clone for QuerySolutions<S>

Source§

fn clone(&self) -> QuerySolutions<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + Rdf> Debug for QuerySolutions<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: Rdf> Display for QuerySolutions<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the query solutions as plain text, one solution per line.

Each solution is displayed using its show() method, which presents variable bindings in the format ?variable -> value. Solutions are separated by blank lines for readability.

Source§

impl<S: Rdf> IntoIterator for QuerySolutions<S>

Source§

type Item = QuerySolution<S>

The type of items yielded by the iterator.

Source§

type IntoIter = IntoIter<QuerySolution<S>>

The iterator type for consuming iteration.

Source§

fn into_iter(self) -> Self::IntoIter

Converts the query solutions into an iterator, consuming the collection.

This allows using QuerySolutions directly in for loops and other iterator contexts. The collection is consumed, yielding owned QuerySolution instances.

Source§

impl<S> Serialize for QuerySolutions<S>
where S: Serialize + Rdf,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<S> Freeze for QuerySolutions<S>

§

impl<S> RefUnwindSafe for QuerySolutions<S>
where <S as Rdf>::Term: RefUnwindSafe,

§

impl<S> Send for QuerySolutions<S>
where <S as Rdf>::Term: Send,

§

impl<S> Sync for QuerySolutions<S>
where <S as Rdf>::Term: Sync,

§

impl<S> Unpin for QuerySolutions<S>
where <S as Rdf>::Term: Unpin,

§

impl<S> UnsafeUnpin for QuerySolutions<S>

§

impl<S> UnwindSafe for QuerySolutions<S>
where <S as Rdf>::Term: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more