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
use crate::table::Table;

#[derive(Debug, Clone, Copy)]
/// A database schema.
/// This type is created by the [`schema`](crate::schema()) function.
pub struct Schema<T> {
    name: T,
}

impl<T> Schema<T> {
    pub(crate) fn new(name: T) -> Self {
        Self { name }
    }

    /// Create a table with this schema.
    pub fn table<U>(&self, name: U) -> Table<U, T>
    where
        T: Clone,
    {
        Table::with_schema(self.name.clone(), name)
    }

    /// Gets the name of the schema, as specified on creation.
    pub fn name(&self) -> &T {
        &self.name
    }
}