pub trait DatabaseAccess: Send + Sync {
// Required methods
fn query(
&self,
sql: &str,
params: &[Value],
) -> Result<Vec<HashMap<String, Value>>, PluginError>;
fn execute(&self, sql: &str, params: &[Value]) -> Result<usize, PluginError>;
fn create_table(
&self,
table_name: &str,
schema_sql: &str,
) -> Result<(), PluginError>;
fn read_host_table(
&self,
table: HostTable,
limit: Option<u32>,
) -> Result<Vec<Value>, PluginError>;
}Required Methods§
Sourcefn query(
&self,
sql: &str,
params: &[Value],
) -> Result<Vec<HashMap<String, Value>>, PluginError>
fn query( &self, sql: &str, params: &[Value], ) -> Result<Vec<HashMap<String, Value>>, PluginError>
Execute a SELECT against plugin-owned tables.
Table names must start with plugin_{plugin_id}_.
Sourcefn execute(&self, sql: &str, params: &[Value]) -> Result<usize, PluginError>
fn execute(&self, sql: &str, params: &[Value]) -> Result<usize, PluginError>
Execute INSERT / UPDATE / DELETE against plugin-owned tables.
Sourcefn create_table(
&self,
table_name: &str,
schema_sql: &str,
) -> Result<(), PluginError>
fn create_table( &self, table_name: &str, schema_sql: &str, ) -> Result<(), PluginError>
Create a table in the plugin’s namespace.
The actual table name will be plugin_{plugin_id}_{table_name}.
Sourcefn read_host_table(
&self,
table: HostTable,
limit: Option<u32>,
) -> Result<Vec<Value>, PluginError>
fn read_host_table( &self, table: HostTable, limit: Option<u32>, ) -> Result<Vec<Value>, PluginError>
Read rows from an approved host table.
Requires database:read:<table> permission.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".