typed_sql/types/
bind.rs

1use crate::sql::CheckedSql;
2
3#[derive(Debug, Clone, Copy)]
4pub struct Bind {
5    pub n: u8,
6}
7
8impl CheckedSql for Bind {}
9
10#[derive(Debug)]
11pub struct Binder {
12    counter: u8,
13}
14
15impl Default for Binder {
16    fn default() -> Self {
17        Self { counter: 1 }
18    }
19}
20
21impl Binder {
22    pub fn bind(&mut self) -> Bind {
23        let n = self.counter;
24        self.counter += 1;
25        Bind { n }
26    }
27}
28
29pub trait Binding {
30    type Bindings;
31
32    fn bindings(binder: &mut Binder) -> Self::Bindings;
33
34    fn write_types(sql: &mut String);
35
36    fn write_values(&self, sql: &mut String);
37}