Skip to main content

DatabaseAccess

Trait DatabaseAccess 

Source
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§

Source

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}_.

Source

fn execute(&self, sql: &str, params: &[Value]) -> Result<usize, PluginError>

Execute INSERT / UPDATE / DELETE against plugin-owned tables.

Source

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}.

Source

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".

Implementors§