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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use crate::traits::signable::Signable;
use serde::de::DeserializeOwned;
use serde::Serialize;
pub trait QueryContext: Serialize + DeserializeOwned {
type Key: Serialize + DeserializeOwned + Ord;
type Value: Serialize + DeserializeOwned;
fn get(&self, key: Self::Key) -> Option<&Self::Value>;
}
pub trait Query: Signable + Serialize + DeserializeOwned {
type Context: QueryContext;
type Location: Serialize + DeserializeOwned + PartialEq;
type Candidate: crate::traits::candidate::Candidate;
fn candidate(&self) -> &Self::Candidate;
fn location(&self) -> &Self::Location;
fn context(&self) -> &Self::Context;
}
pub trait QueryResponse: Signable + Serialize + DeserializeOwned {
type Candidate: crate::traits::candidate::Candidate;
fn preferred_candidate(&self) -> &Self::Candidate;
}
pub trait QueryBuilder {
type Context: QueryContext;
type Location: Serialize + DeserializeOwned + PartialEq;
type Candidate: crate::traits::candidate::Candidate;
type Query: Query<
Context = Self::Context,
Location = Self::Location,
Candidate = Self::Candidate,
>;
fn build_query(
&mut self,
candidate: &Self::Candidate,
location: &Self::Location,
context: &Self::Context,
) -> Self::Query;
}