pub enum AnyConnection {
Postgresql(PgConnection),
Sqlite(SqliteConnection),
}Expand description
Represents a connection to either a PostgreSQL or SQLite database.
Variants§
Postgresql(PgConnection)
A connection to a PostgreSQL database.
This is used when the database_url is a PostgreSQL URL.
§Example
postgres://user:password@localhost:5432/databaseSqlite(SqliteConnection)
A connection to a SQLite database.
This is used when the database_url is a SQLite URL.
Note: The directory where the database is stored will also be populated with a WAL file and a journal file.
§Example
# Relative path
sqlite://database.db
sqlite://data/database.db
# Absolute path
sqlite:///data/database.db
# In-memory database
sqlite://:memory: # In-memory databaseImplementations§
Trait Implementations§
Source§impl Connection for MultiConnection
impl Connection for MultiConnection
Source§type Backend = MultiBackend
type Backend = MultiBackend
The backend this type connects to
Source§fn establish(database_url: &str) -> ConnectionResult<Self>
fn establish(database_url: &str) -> ConnectionResult<Self>
Establishes a new connection to the database Read more
Source§fn set_instrumentation(&mut self, instrumentation: impl Instrumentation)
fn set_instrumentation(&mut self, instrumentation: impl Instrumentation)
Set a specific [
Instrumentation] implementation for this connectionSource§fn set_prepared_statement_cache_size(&mut self, size: CacheSize)
fn set_prepared_statement_cache_size(&mut self, size: CacheSize)
Set the prepared statement cache size to [
CacheSize] for this connectionSource§fn begin_test_transaction(&mut self) -> QueryResult<()>
fn begin_test_transaction(&mut self) -> QueryResult<()>
Creates a transaction that will never be committed. This is useful for
tests. Panics if called while inside of a transaction or
if called with a connection containing a broken transaction
§fn transaction<T, E, F>(&mut self, f: F) -> Result<T, E>
fn transaction<T, E, F>(&mut self, f: F) -> Result<T, E>
Executes the given function inside of a database transaction Read more
Source§impl LoadConnection for MultiConnection
impl LoadConnection for MultiConnection
Source§impl MigrationConnection for MultiConnection
impl MigrationConnection for MultiConnection
Source§impl R2D2Connection for MultiConnection
impl R2D2Connection for MultiConnection
Source§impl SimpleConnection for MultiConnection
impl SimpleConnection for MultiConnection
Source§impl TransactionManager<AnyConnection> for MultiConnection
impl TransactionManager<AnyConnection> for MultiConnection
Source§type TransactionStateData = AnyConnection
type TransactionStateData = AnyConnection
Data stored as part of the connection implementation
to track the current transaction state of a connection
Source§fn begin_transaction(conn: &mut MultiConnection) -> QueryResult<()>
fn begin_transaction(conn: &mut MultiConnection) -> QueryResult<()>
Begin a new transaction or savepoint Read more
Source§fn rollback_transaction(conn: &mut MultiConnection) -> QueryResult<()>
fn rollback_transaction(conn: &mut MultiConnection) -> QueryResult<()>
Rollback the inner-most transaction or savepoint Read more
Source§fn commit_transaction(conn: &mut MultiConnection) -> QueryResult<()>
fn commit_transaction(conn: &mut MultiConnection) -> QueryResult<()>
Commit the inner-most transaction or savepoint Read more
impl ConnectionSealed for MultiConnection
Auto Trait Implementations§
impl Freeze for AnyConnection
impl !RefUnwindSafe for AnyConnection
impl Send for AnyConnection
impl !Sync for AnyConnection
impl Unpin for AnyConnection
impl !UnwindSafe for AnyConnection
Blanket Implementations§
§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read more§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read more§fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
Add an aggregate function filter Read more
§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Add an aggregate function order Read more
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoSql for T
impl<T> IntoSql for T
§impl<C, DB> MigrationHarness<DB> for Cwhere
DB: Backend + DieselReserveSpecialization,
C: Connection<Backend = DB> + MigrationConnection + 'static,
table: BoxedDsl<'static, DB, Output = BoxedSelectStatement<'static, (Text, Timestamp), FromClause<table>, DB>>,
BoxedSelectStatement<'static, Text, FromClause<table>, DB>: LoadQuery<'static, C, MigrationVersion<'static>>,
DefaultValues: QueryFragment<DB>,
str: ToSql<Text, DB>,
impl<C, DB> MigrationHarness<DB> for Cwhere
DB: Backend + DieselReserveSpecialization,
C: Connection<Backend = DB> + MigrationConnection + 'static,
table: BoxedDsl<'static, DB, Output = BoxedSelectStatement<'static, (Text, Timestamp), FromClause<table>, DB>>,
BoxedSelectStatement<'static, Text, FromClause<table>, DB>: LoadQuery<'static, C, MigrationVersion<'static>>,
DefaultValues: QueryFragment<DB>,
str: ToSql<Text, DB>,
§fn run_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
fn run_migration( &mut self, migration: &dyn Migration<DB>, ) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
Apply a single migration Read more
§fn revert_migration(
&mut self,
migration: &dyn Migration<DB>,
) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
fn revert_migration( &mut self, migration: &dyn Migration<DB>, ) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
Revert a single migration Read more
§fn applied_migrations(
&mut self,
) -> Result<Vec<MigrationVersion<'static>>, Box<dyn Error + Sync + Send>>
fn applied_migrations( &mut self, ) -> Result<Vec<MigrationVersion<'static>>, Box<dyn Error + Sync + Send>>
Get a list of already applied migration versions
§fn has_pending_migration<S>(
&mut self,
source: S,
) -> Result<bool, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn has_pending_migration<S>(
&mut self,
source: S,
) -> Result<bool, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Checks if the database represented by the current harness has unapplied migrations
§fn run_pending_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn run_pending_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Execute all unapplied migrations for a given migration source Read more
§fn run_next_migration<S>(
&mut self,
source: S,
) -> Result<MigrationVersion<'_>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn run_next_migration<S>(
&mut self,
source: S,
) -> Result<MigrationVersion<'_>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Execute the next migration from the given migration source
§fn revert_all_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
fn revert_all_migrations<S>(
&mut self,
source: S,
) -> Result<Vec<MigrationVersion<'_>>, Box<dyn Error + Sync + Send>>where
S: MigrationSource<DB>,
Revert all applied migrations from a given migration source
§impl<T> WindowExpressionMethods for T
impl<T> WindowExpressionMethods for T
§fn over(self) -> Self::Outputwhere
Self: OverDsl,
fn over(self) -> Self::Outputwhere
Self: OverDsl,
Turn a function call into a window function call Read more
§fn window_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
fn window_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
Add a filter to the current window function Read more
§fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
Add a partition clause to the current window function Read more
§fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
Add a order clause to the current window function Read more