pub trait DatabaseBackend {
// Required methods
async fn list_databases(&self) -> Result<Vec<String>, AppError>;
async fn list_tables(&self, database: &str) -> Result<Vec<String>, AppError>;
async fn get_table_schema(
&self,
database: &str,
table: &str,
) -> Result<Value, AppError>;
async fn get_table_schema_with_relations(
&self,
database: &str,
table: &str,
) -> Result<Value, AppError>;
async fn execute_query(
&self,
sql: &str,
database: Option<&str>,
) -> Result<Value, AppError>;
async fn create_database(&self, name: &str) -> Result<Value, AppError>;
fn dialect(&self) -> Box<dyn Dialect>;
fn read_only(&self) -> bool;
}Expand description
Operations every database backend must support.
Required Methods§
Sourceasync fn list_databases(&self) -> Result<Vec<String>, AppError>
async fn list_databases(&self) -> Result<Vec<String>, AppError>
Lists all accessible databases.
Sourceasync fn list_tables(&self, database: &str) -> Result<Vec<String>, AppError>
async fn list_tables(&self, database: &str) -> Result<Vec<String>, AppError>
Lists all tables in a database.
Sourceasync fn get_table_schema(
&self,
database: &str,
table: &str,
) -> Result<Value, AppError>
async fn get_table_schema( &self, database: &str, table: &str, ) -> Result<Value, AppError>
Returns column definitions for a table.
Sourceasync fn get_table_schema_with_relations(
&self,
database: &str,
table: &str,
) -> Result<Value, AppError>
async fn get_table_schema_with_relations( &self, database: &str, table: &str, ) -> Result<Value, AppError>
Returns column definitions with foreign key relationships.
Sourceasync fn execute_query(
&self,
sql: &str,
database: Option<&str>,
) -> Result<Value, AppError>
async fn execute_query( &self, sql: &str, database: Option<&str>, ) -> Result<Value, AppError>
Executes a SQL query and returns rows as a JSON array.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.