1use crate::database::{Database, HasArguments};
4use crate::encode::Encode;
5use crate::types::Type;
6
7pub trait Arguments<'q>: Send + Sized + Default {
9 type Database: Database;
10
11 fn reserve(&mut self, additional: usize, size: usize);
14
15 fn add<T>(&mut self, value: T)
17 where
18 T: 'q + Send + Encode<'q, Self::Database> + Type<Self::Database>;
19}
20
21pub trait IntoArguments<'q, DB: HasArguments<'q>>: Sized + Send {
22 fn into_arguments(self) -> <DB as HasArguments<'q>>::Arguments;
23}
24
25#[macro_export]
27#[allow(unused_macros)]
28macro_rules! impl_into_arguments_for_arguments {
29 ($Arguments:path) => {
30 impl<'q>
31 cdbc::arguments::IntoArguments<
32 'q,
33 <$Arguments as cdbc::arguments::Arguments<'q>>::Database,
34 > for $Arguments
35 {
36 fn into_arguments(self) -> $Arguments {
37 self
38 }
39 }
40 };
41}
42
43pub struct ImmutableArguments<'q, DB: HasArguments<'q>>(pub <DB as HasArguments<'q>>::Arguments);
45
46impl<'q, DB: HasArguments<'q>> IntoArguments<'q, DB> for ImmutableArguments<'q, DB> {
47 fn into_arguments(self) -> <DB as HasArguments<'q>>::Arguments {
48 self.0
49 }
50}
51
52