1use crate::schema::Table;
4
5#[derive(Debug, Clone)]
7pub struct TableAlias {
8 pub table: Table,
9 pub alias: String,
10}
11
12impl TableAlias {
13 pub fn new(table: Table, alias: impl Into<String>) -> Self {
15 Self {
16 table,
17 alias: alias.into(),
18 }
19 }
20
21 pub fn alias(&self) -> &str {
23 &self.alias
24 }
25
26 pub fn table(&self) -> &Table {
28 &self.table
29 }
30}
31
32pub trait TableExt {
34 fn alias(self, alias: impl Into<String>) -> TableAlias;
35}
36
37impl TableExt for Table {
38 fn alias(self, alias: impl Into<String>) -> TableAlias {
39 TableAlias::new(self, alias)
40 }
41}