[−][src]Struct bb8::Pool
A generic connection pool.
Methods
impl<M: ManageConnection> Pool<M>[src]
pub fn builder() -> Builder<M>[src]
Returns a Builder instance to configure a new pool.
pub fn state(&self) -> State[src]
Returns information about the current state of the pool.
pub fn run<'a, T, E, U, F>(
&self,
f: F
) -> impl Future<Item = T, Error = RunError<E>> + Send + 'a where
F: FnOnce(M::Connection) -> U + Send + 'a,
U: IntoFuture<Item = (T, M::Connection), Error = (E, M::Connection)> + Send + 'a,
U::Future: Send + 'a,
E: From<M::Error> + Send + 'a,
T: Send + 'a, [src]
&self,
f: F
) -> impl Future<Item = T, Error = RunError<E>> + Send + 'a where
F: FnOnce(M::Connection) -> U + Send + 'a,
U: IntoFuture<Item = (T, M::Connection), Error = (E, M::Connection)> + Send + 'a,
U::Future: Send + 'a,
E: From<M::Error> + Send + 'a,
T: Send + 'a,
Run a closure with a Connection.
The closure will be executed on the tokio event loop provided during
the construction of this pool, so it must be Send. The closure's return
value is also Send so that the Future can be consumed in contexts where
Send is needed.
Futures 0.3 + Async/Await
In order to use this with Futures 0.3 + async/await syntax, use .boxed().compat() on the inner future in order to convert it to a version 0.1 Future.
// Note that this version of `futures` is 0.3 use futures::compat::{Future01CompatExt}; // trait provides `.compat()` async fn future_03_example(client: Client) -> Result<(String, Client), (Error, Client)> { Ok(("Example".to_string(), client)) } client.run(|client| { future_03_example(client).boxed().compat() })
pub fn dedicated_connection(
&self
) -> impl Future<Item = M::Connection, Error = M::Error> + Send[src]
&self
) -> impl Future<Item = M::Connection, Error = M::Error> + Send
Get a new dedicated connection that will not be managed by the pool. An application may want a persistent connection (e.g. to do a postgres LISTEN) that will not be closed or repurposed by the pool.
This method allows reusing the manager's configuration but otherwise bypassing the pool
Trait Implementations
impl<M> Clone for Pool<M> where
M: ManageConnection, [src]
M: ManageConnection,
fn clone(&self) -> Self[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<M> Debug for Pool<M> where
M: ManageConnection, [src]
M: ManageConnection,
Auto Trait Implementations
impl<M> Unpin for Pool<M>
impl<M> Sync for Pool<M> where
<M as ManageConnection>::Connection: Send,
<M as ManageConnection>::Connection: Send,
impl<M> Send for Pool<M> where
<M as ManageConnection>::Connection: Send,
<M as ManageConnection>::Connection: Send,
impl<M> !RefUnwindSafe for Pool<M>
impl<M> !UnwindSafe for Pool<M>
Blanket Implementations
impl<T> From<T> for T[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,