pub struct QueryOptions { /* private fields */ }
Expand description
Options for SPARQL query evaluation.
If the "http-client"
optional feature is enabled,
a simple HTTP 1.1 client is used to execute SPARQL 1.1 Federated Query SERVICE calls.
Usage example disabling the federated query support:
use oxigraph::sparql::QueryOptions;
use oxigraph::store::Store;
let store = Store::new()?;
store.query_opt(
"SELECT * WHERE { SERVICE <https://query.wikidata.org/sparql> {} }",
QueryOptions::default().without_service_handler(),
)?;
Implementations§
Source§impl QueryOptions
impl QueryOptions
Sourcepub fn with_service_handler(
self,
service_handler: impl ServiceHandler + 'static,
) -> Self
pub fn with_service_handler( self, service_handler: impl ServiceHandler + 'static, ) -> Self
Use a given ServiceHandler
to execute SPARQL 1.1 Federated Query SERVICE calls.
Sourcepub fn without_service_handler(self) -> Self
pub fn without_service_handler(self) -> Self
Disables the SERVICE
calls
Sourcepub fn with_custom_function(
self,
name: NamedNode,
evaluator: impl Fn(&[Term]) -> Option<Term> + Send + Sync + 'static,
) -> Self
pub fn with_custom_function( self, name: NamedNode, evaluator: impl Fn(&[Term]) -> Option<Term> + Send + Sync + 'static, ) -> Self
Adds a custom SPARQL evaluation function.
Example with a function serializing terms to N-Triples:
use oxigraph::model::*;
use oxigraph::sparql::{QueryOptions, QueryResults};
use oxigraph::store::Store;
let store = Store::new()?;
if let QueryResults::Solutions(mut solutions) = store.query_opt(
"SELECT (<http://www.w3.org/ns/formats/N-Triples>(1) AS ?nt) WHERE {}",
QueryOptions::default().with_custom_function(
NamedNode::new("http://www.w3.org/ns/formats/N-Triples")?,
|args| args.get(0).map(|t| Literal::from(t.to_string()).into()),
),
)? {
assert_eq!(
solutions.next().unwrap()?.get("nt"),
Some(&Literal::from("\"1\"^^<http://www.w3.org/2001/XMLSchema#integer>").into())
);
}
Trait Implementations§
Source§impl Clone for QueryOptions
impl Clone for QueryOptions
Source§fn clone(&self) -> QueryOptions
fn clone(&self) -> QueryOptions
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for QueryOptions
impl Default for QueryOptions
Source§fn default() -> QueryOptions
fn default() -> QueryOptions
Returns the “default value” for a type. Read more
Source§impl From<QueryOptions> for UpdateOptions
impl From<QueryOptions> for UpdateOptions
Source§fn from(query_options: QueryOptions) -> Self
fn from(query_options: QueryOptions) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for QueryOptions
impl !RefUnwindSafe for QueryOptions
impl Send for QueryOptions
impl Sync for QueryOptions
impl Unpin for QueryOptions
impl !UnwindSafe for QueryOptions
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