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
use std::collections::hash_map::RandomState;
use std::collections::HashMap;
use std::fmt::Debug;
use crate::client::ILazyClient;
use crate::txn::read_only::ReadOnly;
use crate::txn::{IState, TxnReadOnlyType, TxnState, TxnVariant};
use crate::Request;
#[derive(Clone, Debug)]
pub struct BestEffort<C: ILazyClient> {
read_only: ReadOnly<C>,
}
impl<C: ILazyClient> IState for BestEffort<C> {
fn query_request<S: ILazyClient>(
&self,
state: &TxnState<S>,
query: String,
vars: HashMap<String, String, RandomState>,
) -> Request {
let mut request = self.read_only.query_request(state, query, vars);
request.best_effort = true;
request
}
}
pub type TxnBestEffortType<C> = TxnVariant<BestEffort<C>, C>;
impl<C: ILazyClient> TxnReadOnlyType<C> {
pub fn best_effort(self) -> TxnBestEffortType<C> {
TxnVariant {
state: self.state,
extra: BestEffort {
read_only: self.extra,
},
}
}
}