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
use std::marker::PhantomData;

pub trait Table {
    const NAME: &'static str;

    type Fields: Default;

    fn table() -> TableQuery<Self> {
        TableQuery { table: PhantomData }
    }
}

pub trait TableQueryable {
    type Table: Table + ?Sized;
}

pub struct TableQuery<T: ?Sized> {
    table: PhantomData<T>,
}

impl<T: Table + ?Sized> TableQueryable for TableQuery<T> {
    type Table = T;
}

impl<T: ?Sized> Clone for TableQuery<T> {
    fn clone(&self) -> Self {
        *self
    }
}

impl<T: ?Sized> Copy for TableQuery<T> {}