pub trait GraphView:
Sized
+ Send
+ Clone {
type Stream: Send + Unpin + Stream<Item = Result<Arc<Triple>, GraphError>>;
type Filter<T: TripleFilter + Unpin>: GraphView;
type Matches<M: Matches + Unpin>: GraphView;
type CBD<T: AsRef<Term> + Clone + Send>: GraphView;
type SubjectStream<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>;
type SubjectStreamDedup<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>;
type PredicateStreamDedup<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>;
type ObjectStreamDedup<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>;
type PredicateStream<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>;
type ObjectStream<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>;
Show 21 methods
// Required methods
fn stream(
self,
) -> impl Future<Output = Result<Self::Stream, GraphError>> + Send;
fn filter<F>(
self,
filter: F,
) -> impl Future<Output = Result<Self::Filter<F>, GraphError>> + Send
where F: TripleFilter + Unpin;
fn matches<M>(
self,
matches: M,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::Matches<M>, GraphError>> + Send
where M: Matches + Unpin;
fn cbd<T>(
self,
subject: T,
) -> impl Future<Output = Result<Self::CBD<T>, GraphError>> + Send
where T: AsRef<Term> + Clone + Send;
fn subjects<'g>(
self,
predicate: Option<&'g Term>,
object: Option<&'g Term>,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::SubjectStream<'g>, GraphError>> + Send;
fn subjects_dedup<'g>(
self,
predicate: Option<&'g Term>,
object: Option<&'g Term>,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::SubjectStreamDedup<'g>, GraphError>> + Send;
fn predicates_dedup<'g>(
self,
subject: Option<&'g Term>,
object: Option<&'g Term>,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::PredicateStreamDedup<'g>, GraphError>> + Send;
fn objects_dedup<'g>(
self,
subject: Option<&'g Term>,
predicate: Option<&'g Term>,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::ObjectStreamDedup<'g>, GraphError>> + Send;
fn predicates<'g>(
self,
subject: Option<&'g Term>,
object: Option<&'g Term>,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::PredicateStream<'g>, GraphError>> + Send;
fn objects<'g>(
self,
subject: Option<&'g Term>,
predicate: Option<&'g Term>,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::ObjectStream<'g>, GraphError>> + Send;
// Provided methods
fn describe(
self,
subject: &Term,
limit: Option<usize>,
) -> impl Future<Output = Result<Self::Matches<SubjectMatch<'_>>, GraphError>> + Send { ... }
fn subject(
self,
predicate: Option<&Term>,
object: Option<&Term>,
) -> impl Future<Output = Result<Option<Arc<Term>>, GraphError>> + Send { ... }
fn predicate(
self,
subject: Option<&Term>,
object: Option<&Term>,
) -> impl Future<Output = Result<Option<Arc<Term>>, GraphError>> + Send { ... }
fn object(
self,
subject: Option<&Term>,
predicate: Option<&Term>,
) -> impl Future<Output = Result<Option<Arc<Term>>, GraphError>> + Send { ... }
fn contains(
self,
triple: TripleRef<'_>,
) -> impl Future<Output = Result<bool, GraphError>> + Send { ... }
fn isomorphic<G2>(
self,
other: G2,
) -> impl Future<Output = Result<bool, GraphError>> + Send
where G2: GraphView { ... }
fn ground(self) -> impl Future<Output = Result<bool, GraphError>> + Send { ... }
fn default_triple_size_hint() -> usize { ... }
fn default_buf_size_hint() -> usize { ... }
fn triple_size_hint(&self) -> usize { ... }
fn buf_size_hint(&self) -> usize { ... }
}Required Associated Types§
type Stream: Send + Unpin + Stream<Item = Result<Arc<Triple>, GraphError>>
type Filter<T: TripleFilter + Unpin>: GraphView
type Matches<M: Matches + Unpin>: GraphView
type CBD<T: AsRef<Term> + Clone + Send>: GraphView
type SubjectStream<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>
type SubjectStreamDedup<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>
type PredicateStreamDedup<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>
type ObjectStreamDedup<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>
type PredicateStream<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>
type ObjectStream<'g>: Send + Unpin + Stream<Item = Result<Arc<Term>, GraphError>>
Required Methods§
fn stream(self) -> impl Future<Output = Result<Self::Stream, GraphError>> + Send
fn filter<F>(
self,
filter: F,
) -> impl Future<Output = Result<Self::Filter<F>, GraphError>> + Sendwhere
F: TripleFilter + Unpin,
fn matches<M>( self, matches: M, limit: Option<usize>, ) -> impl Future<Output = Result<Self::Matches<M>, GraphError>> + Send
Sourcefn cbd<T>(
self,
subject: T,
) -> impl Future<Output = Result<Self::CBD<T>, GraphError>> + Send
fn cbd<T>( self, subject: T, ) -> impl Future<Output = Result<Self::CBD<T>, GraphError>> + Send
§Example
use taganak_core::prelude::Term;
use taganak_framework::lazy_graph;
use taganak_framework::prelude::{Graph, GraphView};
use futures::StreamExt;
lazy_graph!(graph, r##"
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foo: <https://example.com/foo#> .
@prefix rdfs: <https://www.w3.org/2000/01/rdf-schema#> .
foo:Emil a foo:Turtle ;
foo:age 12 ;
foo:shell [ foo:color "#00ff00" ; foo:tiles 15 ] .
[ rdf:subject foo:Emil ; rdf:predicate foo:age ; rdf:object 12 ; foo:saidBy foo:Emil ] .
foo:Turtle rdfs:label "Schildkröte"@de , "tortoise"@fr .
"##
);
tokio_test::block_on(async {
let mut cbd_stream = graph.view().await.cbd::<Term>("<https://example.com/foo#Emil>".try_into().unwrap()).await.unwrap().stream().await.unwrap();
assert_eq!(cbd_stream.count().await, 9);
});fn subjects<'g>( self, predicate: Option<&'g Term>, object: Option<&'g Term>, limit: Option<usize>, ) -> impl Future<Output = Result<Self::SubjectStream<'g>, GraphError>> + Send
fn subjects_dedup<'g>( self, predicate: Option<&'g Term>, object: Option<&'g Term>, limit: Option<usize>, ) -> impl Future<Output = Result<Self::SubjectStreamDedup<'g>, GraphError>> + Send
fn predicates_dedup<'g>( self, subject: Option<&'g Term>, object: Option<&'g Term>, limit: Option<usize>, ) -> impl Future<Output = Result<Self::PredicateStreamDedup<'g>, GraphError>> + Send
fn objects_dedup<'g>( self, subject: Option<&'g Term>, predicate: Option<&'g Term>, limit: Option<usize>, ) -> impl Future<Output = Result<Self::ObjectStreamDedup<'g>, GraphError>> + Send
fn predicates<'g>( self, subject: Option<&'g Term>, object: Option<&'g Term>, limit: Option<usize>, ) -> impl Future<Output = Result<Self::PredicateStream<'g>, GraphError>> + Send
fn objects<'g>( self, subject: Option<&'g Term>, predicate: Option<&'g Term>, limit: Option<usize>, ) -> impl Future<Output = Result<Self::ObjectStream<'g>, GraphError>> + Send
Provided Methods§
fn describe( self, subject: &Term, limit: Option<usize>, ) -> impl Future<Output = Result<Self::Matches<SubjectMatch<'_>>, GraphError>> + Send
fn subject( self, predicate: Option<&Term>, object: Option<&Term>, ) -> impl Future<Output = Result<Option<Arc<Term>>, GraphError>> + Send
fn predicate( self, subject: Option<&Term>, object: Option<&Term>, ) -> impl Future<Output = Result<Option<Arc<Term>>, GraphError>> + Send
fn object( self, subject: Option<&Term>, predicate: Option<&Term>, ) -> impl Future<Output = Result<Option<Arc<Term>>, GraphError>> + Send
fn contains( self, triple: TripleRef<'_>, ) -> impl Future<Output = Result<bool, GraphError>> + Send
Sourcefn isomorphic<G2>(
self,
other: G2,
) -> impl Future<Output = Result<bool, GraphError>> + Sendwhere
G2: GraphView,
fn isomorphic<G2>(
self,
other: G2,
) -> impl Future<Output = Result<bool, GraphError>> + Sendwhere
G2: GraphView,
use taganak_core::prelude::Term;
use taganak_framework::lazy_graph;
use taganak_framework::prelude::{Graph, GraphView};
use futures::StreamExt;
lazy_graph!(graph1, r##"
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foo: <https://example.com/foo#> .
@prefix rdfs: <https://www.w3.org/2000/01/rdf-schema#> .
foo:Emil a foo:Turtle ;
foo:age 12 ;
foo:shell [ foo:color "#00ff00" ; foo:tiles 15 ] .
[ rdf:subject foo:Emil ; rdf:predicate foo:age ; rdf:object 12 ; foo:saidBy foo:Emil ] .
foo:Turtle rdfs:label "Schildkröte"@de , "tortoise"@fr .
"##
);
lazy_graph!(graph2, r##"
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foo: <https://example.com/foo#> .
@prefix rdfs: <https://www.w3.org/2000/01/rdf-schema#> .
foo:Emil a foo:Turtle ;
foo:age 12 ;
foo:shell [ foo:color "#00ff00" ; foo:tiles 15 ] .
[ rdf:subject foo:Emil ; rdf:predicate foo:age ; rdf:object 12 ; foo:saidBy foo:Emil ] .
foo:Turtle rdfs:label "Schildkröte"@de , "tortoise"@fr .
"##
);
assert!(graph1.view().await.isomorphic(graph2.view().await).await.unwrap());
let emil: Term = "<https://example.com/foo#Emil>".try_into().unwrap();
assert!(!graph1.view().await.isomorphic(graph2.view().await.describe(&emil,
None).await.unwrap()).await.unwrap());
Sourcefn ground(self) -> impl Future<Output = Result<bool, GraphError>> + Send
fn ground(self) -> impl Future<Output = Result<bool, GraphError>> + Send
Checks whether graph is ground as defined by RDF Concepts and Abstract Syntax
A graph is ground if all triples in it are ground (cf. super::triples::Triple::ground).
§Example
use taganak_framework::lazy_graph;
use taganak_core::prelude::Term;
use taganak_framework::prelude::{Graph, GraphView};
use futures::StreamExt;
lazy_graph!(GRAPH, r##"
@base <https://example.com/> .
<t1> a <Foo> ;
<sampleNumber> 12 .
<t2> a <Foo> ;
<sampleList> ( 12 15 ) .
"##);
tokio_test::block_on(async {
assert_eq!(GRAPH.view().await.ground().await.unwrap(), false);
assert_eq!(GRAPH.view().await
.cbd::<Term>("<https://example.com/t1>".try_into().unwrap()).await.unwrap()
.ground().await.unwrap(),
true);
});fn default_triple_size_hint() -> usize
fn default_buf_size_hint() -> usize
fn triple_size_hint(&self) -> usize
fn buf_size_hint(&self) -> usize
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.