1use std::{collections::HashSet, vec::IntoIter};
2
3use crate::{Query, Triple};
4
5pub enum Neigh<S>
6where
7 S: Query,
8{
9 Direct { p: S::IRI, o: S::Term },
10 Inverse { s: S::Subject, p: S::IRI },
11}
12
13impl<S> Neigh<S>
14where
15 S: Query,
16{
17 pub fn direct(pred: S::IRI, object: S::Term) -> Neigh<S> {
18 Neigh::Direct { p: pred, o: object }
19 }
20
21 pub fn inverse(pred: S::IRI, subject: S::Subject) -> Neigh<S> {
22 Neigh::Inverse {
23 p: pred,
24 s: subject,
25 }
26 }
27}
28
29pub struct NeighsIterator<S>
32where
33 S: Query,
34{
35 _term: S::Term,
36 _neigh_iter: IntoIter<Neigh<S>>,
37}
38
39impl<S> NeighsIterator<S>
40where
41 S: Query,
42{
43 pub fn new(term: S::Term, rdf: S) -> Result<NeighsIterator<S>, S::Err> {
44 match term.try_into() {
45 Ok(subject) => {
46 let subject: S::Subject = subject;
47 let preds: HashSet<S::IRI> = rdf
48 .triples_with_subject(subject)?
49 .map(Triple::into_predicate)
50 .collect();
51 let _qs = preds.into_iter();
52 todo!(); }
58 Err(_) => {
59 todo!()
60 }
61 }
62 }
64}
65
66impl<S> FromIterator<Neigh<S>> for NeighsIterator<S>
67where
68 S: Query,
69{
70 fn from_iter<T>(_t: T) -> Self
71 where
72 T: IntoIterator,
73 {
74 todo!()
75 }
76}
77
78impl<S> Iterator for NeighsIterator<S>
79where
80 S: Query,
81{
82 type Item = Neigh<S>;
83
84 fn next(&mut self) -> Option<Self::Item> {
85 todo!()
86 }
87}