derive_sql/traits/
table.rs1use super::*;
2
3pub trait TableFlavoredStatement {
5 fn create_stmt<C, R>(&self, conn: &C) -> Result<String> where C: Connection<R>, R: Row;
7
8 fn create_if_not_exist_stmt<C, R>(&self, conn: &C) -> Result<String> where C: Connection<R>, R: Row;
10
11 fn drop_stmt<C, R>(&self, conn: &C) -> Result<String> where C: Connection<R>, R: Row;
13}
14
15pub trait TableStatement {
17 fn create_stmt(&self) -> Result<String>;
18 fn create_if_not_exist_stmt(&self) -> Result<String>;
19 fn drop_stmt(&self) -> Result<String>;
20}
21
22impl<S> TableFlavoredStatement for S
24where S: TableStatement
25{
26 fn create_stmt<C, R>(&self, _: &C) -> Result<String> where C: Connection<R>, R: Row {
27 TableStatement::create_stmt(self)
28 }
29 fn create_if_not_exist_stmt<C, R>(&self, _: &C) -> Result<String> where C: Connection<R>, R: Row {
30 TableStatement::create_if_not_exist_stmt(self)
31 }
32 fn drop_stmt<C, R>(&self, _: &C) -> Result<String> where C: Connection<R>, R: Row {
33 TableStatement::drop_stmt(self)
34 }
35}
36
37pub trait Table<C, R>
39where C: Connection<R>,
40 R: Row,
41{
42 fn create(&self, conn: &mut C) -> Result<()>;
44
45 fn create_if_not_exist(&self, conn: &mut C) -> Result<()>;
47
48 fn drop(&self, conn: &mut C) -> Result<()>;
50}