Trait ConnectionPool

Source
pub trait ConnectionPool: Sized {
    // Required methods
    fn new<S>(
        driver_name: S,
        driver: Arc<Mutex<BoxedDriver>>,
        url: S,
    ) -> Result<Self>
       where S: Into<String> + AsRef<str>;
    fn get_conn(&self) -> Result<Box<dyn Connection>>;
    fn release_conn(&self, conn: Box<dyn Connection>);
}
Expand description

Database connection pool trait.

Required Methods§

Source

fn new<S>( driver_name: S, driver: Arc<Mutex<BoxedDriver>>, url: S, ) -> Result<Self>
where S: Into<String> + AsRef<str>,

Create new connection pool

§Arguments
  • driver - SQL thread safe driver instance
  • url - SQL driver connect url
Source

fn get_conn(&self) -> Result<Box<dyn Connection>>

Get new connection from pool or create new one from driver.

Source

fn release_conn(&self, conn: Box<dyn Connection>)

Release one connection return to pool.

§Arguments
  • conn - Unused connection instance

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.

Implementors§