diesel::connection

Trait 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,