Struct QueryOptions
pub struct QueryOptions {
http_timeout: Option<Duration>,
http_redirection_limit: usize,
inner: QueryEvaluator,
}
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(),
)?;
Fieldsยง
ยงhttp_timeout: Option<Duration>
ยงhttp_redirection_limit: usize
ยงinner: QueryEvaluator
Implementationsยง
ยงimpl QueryOptions
impl QueryOptions
pub fn with_service_handler(
self,
service_handler: impl ServiceHandler + 'static,
) -> QueryOptions
pub fn with_service_handler( self, service_handler: impl ServiceHandler + 'static, ) -> QueryOptions
Use a given ServiceHandler
to execute SPARQL 1.1 Federated Query SERVICE calls.
pub fn without_service_handler(self) -> QueryOptions
pub fn without_service_handler(self) -> QueryOptions
Disables the SERVICE
calls
pub fn with_custom_function(
self,
name: NamedNode,
evaluator: impl Fn(&[Term]) -> Option<Term> + Send + Sync + 'static,
) -> QueryOptions
pub fn with_custom_function( self, name: NamedNode, evaluator: impl Fn(&[Term]) -> Option<Term> + Send + Sync + 'static, ) -> QueryOptions
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ยง
ยงimpl Clone for QueryOptions
impl Clone for QueryOptions
ยงfn clone(&self) -> QueryOptions
fn clone(&self) -> QueryOptions
Returns a duplicate 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 moreยงimpl Default for QueryOptions
impl Default for QueryOptions
ยงfn default() -> QueryOptions
fn default() -> QueryOptions
Returns the โdefault valueโ for a type. Read more
ยงimpl From<QueryOptions> for UpdateOptions
impl From<QueryOptions> for UpdateOptions
ยงfn from(query_options: QueryOptions) -> UpdateOptions
fn from(query_options: QueryOptions) -> UpdateOptions
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ยง
ยงimpl<T> ArchivePointee for T
impl<T> ArchivePointee for T
ยงtype ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
ยงfn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
ยงimpl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
ยงfn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
ยงimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
ยงfn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.ยงfn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.ยงfn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
โs vtable from &Trait
โs.ยงfn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
โs vtable from &mut Trait
โs.ยงimpl<T> DowncastSend for T
impl<T> DowncastSend for T
ยงimpl<T> DowncastSync for T
impl<T> DowncastSync for T
ยงimpl<T> Instrument for T
impl<T> Instrument for T
ยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
ยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more