-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathqueryable.rs
More file actions
33 lines (28 loc) · 857 Bytes
/
queryable.rs
File metadata and controls
33 lines (28 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// This is free and unencumbered software released into the public domain.
extern crate alloc;
use alloc::vec;
use rdf_model::Enumerable;
use crate::{graph_pattern::GraphPattern, pattern::Pattern, query::Query, solutions::Solutions};
pub trait Queryable: Enumerable {
fn query(&self, pattern: impl Into<GraphPattern>) -> Solutions
where
Self: Sized,
{
match pattern.into() {
GraphPattern::BasicGraphPattern(query) => self.query_execute(query),
GraphPattern::TriplePattern(pattern) => self.query_execute(Query::new(vec![pattern])),
}
}
fn query_execute(&self, query: Query) -> Solutions
where
Self: Sized,
{
query.execute(self)
}
fn query_pattern(&self, pattern: &Pattern) -> Self
where
Self: Sized,
{
self.grep(pattern)
}
}