1use async_trait::async_trait;
2use crate::error::ReflectError;
3use crate::metadata::{Column, ForeignKey, Index, PrimaryKey};
4
5#[derive(Debug, Clone)]
6pub struct TableInfo {
7 pub name: String,
8 pub is_view: bool,
9}
10
11#[async_trait]
12pub trait Executor: Send + Sync {
13 async fn fetch_tables(
14 &self,
15 schema: Option<&str>,
16 include_views: bool,
17 ) -> Result<Vec<TableInfo>, ReflectError>;
18
19 async fn fetch_columns(
20 &self,
21 table: &str,
22 schema: Option<&str>,
23 ) -> Result<Vec<Column>, ReflectError>;
24
25 async fn fetch_primary_key(
26 &self,
27 table: &str,
28 schema: Option<&str>,
29 ) -> Result<Option<PrimaryKey>, ReflectError>;
30
31 async fn fetch_foreign_keys(
32 &self,
33 table: &str,
34 schema: Option<&str>,
35 ) -> Result<Vec<ForeignKey>, ReflectError>;
36
37 async fn fetch_indexes(
38 &self,
39 table: &str,
40 schema: Option<&str>,
41 ) -> Result<Vec<Index>, ReflectError>;
42}