Skip to main content

Pool

Struct Pool 

Source
pub struct Pool { /* private fields */ }
Expand description

connection pool for a set of connections to database. Can be used as entry point of query

§Examples

let pool = xitca_postgres::pool::Pool::builder("db_url").build()?;
xitca_postgres::Statement::named("SELECT 1", &[]).bind_none().execute(&pool).await?;

§Caching

When connection pool is used as executor through Execute::query and Execute::execute methods it would prepare and cache statement for reuse. For selective caching consider use PoolConnection

Implementations§

Source§

impl Pool

Source

pub fn builder<C>(cfg: C) -> PoolBuilder
where Config: TryFrom<C>, Error: From<<Config as TryFrom<C>>::Error>,

start a builder of pool where it’s behavior can be configured.

Source

pub async fn get(&self) -> Result<PoolConnection<'_>, Error>

try to get a connection from pool. when pool is empty it will try to spawn new connection to database and if the process failed the outcome will return as Error

Source

pub fn config(&self) -> &Config

get configration of current connection pool.

Trait Implementations§

Source§

impl<'c, 's> Execute<&'c Pool> for &'s str
where 's: 'c,

Available on non-crate feature nightly only.
Source§

type ExecuteOutput = Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'c>>

outcome of execute. used for single time database response: number of rows affected by execution for example.
Source§

type QueryOutput = Pin<Box<dyn Future<Output = Result<GenericRowStream<Vec<Column>, NoTyped>, Error>> + Send + 'c>>

outcome of query. used for repeated database response: database rows for example Read more
Source§

fn execute(self, pool: &'c Pool) -> Self::ExecuteOutput

define how a statement is executed with single time response
Source§

fn query(self, pool: &'c Pool) -> Self::QueryOutput

define how a statement is queried with repeated response
Source§

impl<'c, 's, P, const N: usize> Execute<&'c Pool> for [StatementQuery<'s, P>; N]
where P: AsParams + Send + 'c, 's: 'c,

Available on non-crate feature nightly only.
Source§

type ExecuteOutput = Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'c>>

outcome of execute. used for single time database response: number of rows affected by execution for example.
Source§

type QueryOutput = Pin<Box<dyn Future<Output = Result<Vec<GenericRowStream<Arc<[Column]>, Typed>>, Error>> + Send + 'c>>

outcome of query. used for repeated database response: database rows for example Read more
Source§

fn execute(self, pool: &'c Pool) -> Self::ExecuteOutput

define how a statement is executed with single time response
Source§

fn query(self, pool: &'c Pool) -> Self::QueryOutput

define how a statement is queried with repeated response
Source§

impl<'c, 's, P> Execute<&'c Pool> for StatementQuery<'s, P>
where P: AsParams + Send + 'c, 's: 'c,

Available on non-crate feature nightly only.
Source§

type ExecuteOutput = Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'c>>

outcome of execute. used for single time database response: number of rows affected by execution for example.
Source§

type QueryOutput = Pin<Box<dyn Future<Output = Result<GenericRowStream<Arc<[Column]>, Typed>, Error>> + Send + 'c>>

outcome of query. used for repeated database response: database rows for example Read more
Source§

fn execute(self, pool: &'c Pool) -> Self::ExecuteOutput

define how a statement is executed with single time response
Source§

fn query(self, pool: &'c Pool) -> Self::QueryOutput

define how a statement is queried with repeated response
Source§

impl<'c, 's, P> Execute<&'c Pool> for Vec<StatementQuery<'s, P>>
where P: AsParams + Send + 'c, 's: 'c,

Available on non-crate feature nightly only.
Source§

type ExecuteOutput = Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'c>>

outcome of execute. used for single time database response: number of rows affected by execution for example.
Source§

type QueryOutput = Pin<Box<dyn Future<Output = Result<Vec<GenericRowStream<Arc<[Column]>, Typed>>, Error>> + Send + 'c>>

outcome of query. used for repeated database response: database rows for example Read more
Source§

fn execute(self, pool: &'c Pool) -> Self::ExecuteOutput

define how a statement is executed with single time response
Source§

fn query(self, pool: &'c Pool) -> Self::QueryOutput

define how a statement is queried with repeated response

Auto Trait Implementations§

§

impl !Freeze for Pool

§

impl !RefUnwindSafe for Pool

§

impl Send for Pool

§

impl Sync for Pool

§

impl Unpin for Pool

§

impl UnsafeUnpin for Pool

§

impl !UnwindSafe for Pool

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V