diesel_async::pooled_connection

Struct AsyncDieselConnectionManager

Source
pub struct AsyncDieselConnectionManager<C> { /* private fields */ }
Available on crate feature pool only.
Expand description

An connection manager for use with diesel-async.

See the concrete pool implementations for examples:

Implementations§

Source§

impl<C> AsyncDieselConnectionManager<C>
where C: AsyncConnection + 'static,

Source

pub fn new(connection_url: impl Into<String>) -> Self
where C: AsyncConnection + 'static,

Returns a new connection manager, which establishes connections to the given database URL.

Source

pub fn new_with_config( connection_url: impl Into<String>, manager_config: ManagerConfig<C>, ) -> Self

Returns a new connection manager, which establishes connections with the given database URL and that uses the specified configuration

Trait Implementations§

Source§

impl<C> Debug for AsyncDieselConnectionManager<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C> ManageConnection for AsyncDieselConnectionManager<C>
where C: PoolableConnection + 'static, select<AsExprOf<i32, Integer>>: ExecuteDsl<C>, SqlQuery: QueryFragment<C::Backend>,

Available on crate feature bb8 only.
Source§

type Connection = C

The connection type this manager deals with.
Source§

type Error = PoolError

The error type returned by Connections.
Source§

fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to create a new connection.
Source§

fn is_valid<'life0, 'life1, 'async_trait>( &'life0 self, conn: &'life1 mut Self::Connection, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Determines if the connection is still connected to the database.
Source§

fn has_broken(&self, conn: &mut Self::Connection) -> bool

Synchronously determine if the connection is no longer usable, if possible.
Source§

impl<C> Manager for AsyncDieselConnectionManager<C>
where C: PoolableConnection + Send + 'static, select<AsExprOf<i32, Integer>>: ExecuteDsl<C>, SqlQuery: QueryFragment<C::Backend>,

Available on crate feature deadpool only.
Source§

type Type = C

Type of Objects that this Manager creates and recycles.
Source§

type Error = PoolError

Error that this Manager can return when creating and/or recycling Objects.
Source§

async fn create(&self) -> Result<Self::Type, Self::Error>

Creates a new instance of Manager::Type.
Source§

async fn recycle( &self, obj: &mut Self::Type, _: &Metrics, ) -> RecycleResult<Self::Error>

Tries to recycle an instance of Manager::Type. Read more
Source§

fn detach(&self, _obj: &mut Self::Type)

Detaches an instance of Manager::Type from this Manager. Read more
Source§

impl<C> Manager for AsyncDieselConnectionManager<C>
where C: PoolableConnection + 'static, select<AsExprOf<i32, Integer>>: ExecuteDsl<C>, SqlQuery: QueryFragment<C::Backend>,

Available on crate feature mobc only.
Source§

type Connection = C

The connection type this manager deals with.
Source§

type Error = PoolError

The error type returned by Connections.
Source§

fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempts to create a new connection.
Source§

fn check<'life0, 'async_trait>( &'life0 self, conn: Self::Connection, ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Determines if the connection is still connected to the database when check-out. Read more
Source§

fn spawn_task<T>(&self, task: T)
where T: Future + Send + 'static, <T as Future>::Output: Send + 'static,

Spawns a new asynchronous task.
Source§

fn validate(&self, _conn: &mut Self::Connection) -> bool

Quickly determines a connection is still valid when check-in.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, Conn> RunQueryDsl<Conn> for T

Source§

fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> Conn::ExecuteFuture<'conn, 'query>
where Conn: AsyncConnection + Send, Self: ExecuteDsl<Conn> + 'query,

Executes the given command, returning the number of rows affected. Read more
Source§

fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> LoadFuture<'conn, 'query, Self, Conn, U>
where U: Send, Conn: AsyncConnection, Self: LoadQuery<'query, Conn, U> + 'query,

Executes the given query, returning a Vec with the returned rows. Read more
Source§

fn load_stream<'conn, 'query, U>( self, conn: &'conn mut Conn, ) -> Self::LoadFuture<'conn>
where Conn: AsyncConnection, U: 'conn, Self: LoadQuery<'query, Conn, U> + 'query,

Executes the given query, returning a Stream with the returned rows. Read more
Source§

fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> GetResult<'conn, 'query, Self, Conn, U>
where U: Send + 'conn, Conn: AsyncConnection, Self: LoadQuery<'query, Conn, U> + 'query,

Runs the command, and returns the affected row. Read more
Source§

fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> LoadFuture<'conn, 'query, Self, Conn, U>
where U: Send, Conn: AsyncConnection, Self: LoadQuery<'query, Conn, U> + 'query,

Runs the command, returning an Vec with the affected rows. Read more
Source§

fn first<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> GetResult<'conn, 'query, Limit<Self>, Conn, U>
where U: Send + 'conn, Conn: AsyncConnection, Self: LimitDsl, Limit<Self>: LoadQuery<'query, Conn, U> + Send + 'query,

Attempts to load a single record. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T