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
53
54
55
56
57
58
59
use crate::database::Database;
use crate::encode::Encode;
use crate::types::HasSqlType;
pub trait Arguments: Send + Sized + Default + 'static {
type Database: Database + ?Sized;
#[inline]
fn is_empty(&self) -> bool {
self.len() == 0
}
fn len(&self) -> usize;
fn size(&self) -> usize;
fn reserve(&mut self, len: usize, size: usize);
fn add<T>(&mut self, value: T)
where
Self::Database: HasSqlType<T>,
T: Encode<Self::Database>;
}
pub trait IntoArguments<DB>
where
DB: Database,
{
fn into_arguments(self) -> DB::Arguments;
}
impl<A> IntoArguments<A::Database> for A
where
A: Arguments,
A::Database: Database<Arguments = Self> + Sized,
{
#[inline]
fn into_arguments(self) -> Self {
self
}
}
#[doc(hidden)]
pub struct ImmutableArguments<DB: Database>(pub DB::Arguments);
impl<DB: Database> IntoArguments<DB> for ImmutableArguments<DB> {
fn into_arguments(self) -> <DB as Database>::Arguments {
self.0
}
}