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)
Implementations§
Source§impl QueryResults
impl QueryResults
Sourcepub fn read(
reader: impl Read + 'static,
format: QueryResultsFormat,
) -> Result<Self, QueryResultsParseError>
pub fn read( reader: impl Read + 'static, format: QueryResultsFormat, ) -> Result<Self, QueryResultsParseError>
Reads a SPARQL query results serialization.
Sourcepub fn write<W: Write>(
self,
writer: W,
format: QueryResultsFormat,
) -> Result<W, EvaluationError>
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()
);
Sourcepub fn write_graph<W: Write>(
self,
writer: W,
format: impl Into<RdfFormat>,
) -> Result<W, EvaluationError>
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
impl From<QuerySolutionIter> for QueryResults
Source§fn from(value: QuerySolutionIter) -> Self
fn from(value: QuerySolutionIter) -> Self
Converts to this type from the input type.
Source§impl<R: Read + 'static> From<ReaderQueryResultsParserOutput<R>> for QueryResults
impl<R: Read + 'static> From<ReaderQueryResultsParserOutput<R>> for QueryResults
Source§fn from(reader: ReaderQueryResultsParserOutput<R>) -> Self
fn from(reader: ReaderQueryResultsParserOutput<R>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for QueryResults
impl !RefUnwindSafe for QueryResults
impl !Send for QueryResults
impl !Sync for QueryResults
impl Unpin for QueryResults
impl !UnwindSafe for QueryResults
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more