Skip to main content

ConnectionPool

Trait ConnectionPool 

Source
pub trait ConnectionPool: Send + Sync {
    // Required methods
    fn execute_query(
        &self,
        sql: &str,
        params: &[&dyn Display],
    ) -> Result<Vec<HashMap<String, String>>>;
    fn execute_command(&self, sql: &str, params: &[&dyn Display]) -> Result<u64>;
    fn begin_transaction(&self) -> Result<Box<dyn Transaction>>;
    fn active_connections(&self) -> u32;
    fn max_connections(&self) -> u32;
}
Expand description

Connection pool trait for managing database connections

Required Methods§

Source

fn execute_query( &self, sql: &str, params: &[&dyn Display], ) -> Result<Vec<HashMap<String, String>>>

Execute a query and return results

Source

fn execute_command(&self, sql: &str, params: &[&dyn Display]) -> Result<u64>

Execute a command (INSERT, UPDATE, DELETE)

Source

fn begin_transaction(&self) -> Result<Box<dyn Transaction>>

Begin a transaction

Source

fn active_connections(&self) -> u32

Get the number of active connections

Source

fn max_connections(&self) -> u32

Get the maximum number of connections

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§