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
use crate::sql::CheckedSql; #[derive(Debug, Clone, Copy)] pub struct Bind { pub n: u8, } impl CheckedSql for Bind {} #[derive(Debug)] pub struct Binder { counter: u8, } impl Default for Binder { fn default() -> Self { Self { counter: 1 } } } impl Binder { pub fn bind(&mut self) -> Bind { let n = self.counter; self.counter += 1; Bind { n } } } pub trait Binding { type Bindings; fn bindings(binder: &mut Binder) -> Self::Bindings; fn write_types(sql: &mut String); fn write_values(&self, sql: &mut String); }