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 rsfbclient_core::{FbError, FromRow, IntoParams};
pub trait Queryable<'a, R>
where
R: FromRow + 'a,
{
type Iter: Iterator<Item = Result<R, FbError>> + 'a;
fn query_iter<P>(&'a mut self, sql: &str, params: P) -> Result<Self::Iter, FbError>
where
P: IntoParams;
fn query<P>(&'a mut self, sql: &str, params: P) -> Result<Vec<R>, FbError>
where
P: IntoParams,
{
self.query_iter(sql, params)?.collect()
}
fn query_first<P>(&'a mut self, sql: &str, params: P) -> Result<Option<R>, FbError>
where
P: IntoParams,
{
self.query_iter(sql, params)?.next().transpose()
}
}
pub trait Execute {
fn execute<P>(&mut self, sql: &str, params: P) -> Result<(), FbError>
where
P: IntoParams;
}