1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use super::*;

pub trait TableStatement {
  fn create_stmt(&self) -> Result<String>;
  fn create_if_not_exist_stmt(&self) -> Result<String>;
  fn drop_stmt(&self) -> Result<String>;
}

/// Trait to manage table - create, check if exists, and drop
pub trait Table<C, R>
where C: Connection<R>,
      R: Row,
{
  /// Create a table. Error if the table already exists
  fn create(&self, conn: &mut C) -> Result<()>;

  /// Create a table if it does not already exist
  fn create_if_not_exist(&self, conn: &mut C) -> Result<()>;

  /// Delete the table
  fn drop(&self, conn: &mut C) -> Result<()>;
}