Trait diesel::connection::BoxableConnection

source ·
pub trait BoxableConnection<DB: Backend>: SimpleConnection + Any {
    // Required method
    fn as_any(&self) -> &dyn Any;
}
Expand description

A variant of the Connection trait that is usable with dynamic dispatch

If you are looking for a way to use pass database connections for different database backends around in your application this trait won’t help you much. Normally you should only need to use this trait if you are interacting with a connection passed to a Migration

Required Methods§

source

fn as_any(&self) -> &dyn Any

Available on crate feature i-implement-a-third-party-backend-and-opt-into-breaking-changes only.

Maps the current connection to std::any::Any

Implementations§

source§

impl<DB: Backend + 'static> dyn BoxableConnection<DB>

source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: Connection<Backend = DB> + 'static,

Downcast the current connection to a specific connection type.

This will return None if the underlying connection does not match the corresponding type, otherwise a reference to the underlying connection is returned

source

pub fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: Connection<Backend = DB> + 'static,

Downcast the current connection to a specific mutable connection type.

This will return None if the underlying connection does not match the corresponding type, otherwise a mutable reference to the underlying connection is returned

source

pub fn is<T>(&self) -> bool
where T: Connection<Backend = DB> + 'static,

Check if the current connection is a specific connection type

Implementors§

source§

impl<C> BoxableConnection<<C as Connection>::Backend> for C
where C: Connection + Any,