oxigraph::sparql

Enum QueryResults

Source
pub enum QueryResults {
    Solutions(QuerySolutionIter),
    Boolean(bool),
    Graph(QueryTripleIter),
}
Expand description

Results of a SPARQL query.

Variants§

§

Solutions(QuerySolutionIter)

Results of a SELECT query.

§

Boolean(bool)

Result of a ASK query.

§

Graph(QueryTripleIter)

Results of a CONSTRUCT or DESCRIBE query.

Implementations§

Source§

impl QueryResults

Source

pub fn read( reader: impl Read + 'static, format: QueryResultsFormat, ) -> Result<Self, QueryResultsParseError>

Reads a SPARQL query results serialization.

Source

pub fn write<W: Write>( self, writer: W, format: QueryResultsFormat, ) -> Result<W, EvaluationError>

Writes the query results (solutions or boolean).

This method fails if it is called on the Graph results.

use oxigraph::store::Store;
use oxigraph::model::*;
use oxigraph::sparql::results::QueryResultsFormat;

let store = Store::new()?;
let ex = NamedNodeRef::new("http://example.com")?;
store.insert(QuadRef::new(ex, ex, ex, GraphNameRef::DefaultGraph))?;

let results = store.query("SELECT ?s WHERE { ?s ?p ?o }")?;
assert_eq!(
    results.write(Vec::new(), QueryResultsFormat::Json)?,
    r#"{"head":{"vars":["s"]},"results":{"bindings":[{"s":{"type":"uri","value":"http://example.com"}}]}}"#.as_bytes()
);
Source

pub fn write_graph<W: Write>( self, writer: W, format: impl Into<RdfFormat>, ) -> Result<W, EvaluationError>

Writes the graph query results.

This method fails if it is called on the Solution or Boolean results.

use oxigraph::io::RdfFormat;
use oxigraph::model::*;
use oxigraph::store::Store;

let graph = "<http://example.com> <http://example.com> <http://example.com> .\n";

let store = Store::new()?;
store.load_graph(
    graph.as_bytes(),
    RdfFormat::NTriples,
    GraphName::DefaultGraph,
    None,
)?;

let results = store.query("CONSTRUCT WHERE { ?s ?p ?o }")?;
assert_eq!(
    results.write_graph(Vec::new(), RdfFormat::NTriples)?,
    graph.as_bytes()
);

Trait Implementations§

Source§

impl From<QuerySolutionIter> for QueryResults

Source§

fn from(value: QuerySolutionIter) -> Self

Converts to this type from the input type.
Source§

impl<R: Read + 'static> From<ReaderQueryResultsParserOutput<R>> for QueryResults

Source§

fn from(reader: ReaderQueryResultsParserOutput<R>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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

Source§

type Output = T

Should always be Self
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