Enum autopulse::db::conn::AnyConnection

source ·
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/database
§

Sqlite(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 database

Implementations§

source§

impl AnyConnection

source

pub fn pre_init(database_url: &str) -> Result<()>

source

pub fn init(&mut self) -> Result<()>

source

pub fn migrate(&mut self) -> Result<()>

source

pub fn save_changes(&mut self, ev: &mut ScanEvent) -> Result<ScanEvent>

source

pub fn insert_and_return(&mut self, ev: &NewScanEvent) -> Result<ScanEvent>

Trait Implementations§

source§

impl Connection for MultiConnection

source§

type Backend = MultiBackend

The backend this type connects to
source§

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)

Set a specific [Instrumentation] implementation for this connection
source§

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>
where F: FnOnce(&mut Self) -> Result<T, E>, E: From<Error>,

Executes the given function inside of a database transaction Read more
§

fn test_transaction<T, E, F>(&mut self, f: F) -> T
where F: FnOnce(&mut Self) -> Result<T, E>, E: Debug,

Executes the given function inside a transaction, but does not commit it. Panics if the given function returns an error. Read more
source§

impl LoadConnection for MultiConnection

source§

type Cursor<'conn, 'query> = MultiCursor<'conn, 'query>

The cursor type returned by [LoadConnection::load] Read more
source§

type Row<'conn, 'query> = MultiRow<'conn, 'query>

The row type used as Iterator::Item for the iterator implementation of [LoadConnection::Cursor]
source§

impl MigrationConnection for MultiConnection

source§

fn setup(&mut self) -> QueryResult<usize>

Setup the following table: Read more
source§

impl R2D2Connection for MultiConnection

source§

fn ping(&mut self) -> QueryResult<()>

Check if a connection is still valid
source§

fn is_broken(&mut self) -> bool

Checks if the connection is broken and should not be reused Read more
source§

impl SimpleConnection for MultiConnection

source§

fn batch_execute(&mut self, query: &str) -> QueryResult<()>

Execute multiple SQL statements within the same string. Read more
source§

impl TransactionManager<AnyConnection> for MultiConnection

source§

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<()>

Begin a new transaction or savepoint Read more
source§

fn rollback_transaction(conn: &mut MultiConnection) -> QueryResult<()>

Rollback the inner-most transaction or savepoint Read more
source§

fn commit_transaction(conn: &mut MultiConnection) -> QueryResult<()>

Commit the inner-most transaction or savepoint Read more
§

fn transaction<F, R, E>(conn: &mut Conn, callback: F) -> Result<R, E>
where F: FnOnce(&mut Conn) -> Result<R, E>, E: From<Error>,

Executes the given function inside of a database transaction Read more
source§

impl ConnectionSealed for MultiConnection

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
§

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

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> IntoSql for T

§

fn into_sql<T>(self) -> Self::Expression
where Self: Sized + AsExpression<T>, T: SqlType + TypedExpressionType,

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

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
§

impl<'b, C, DB> MigrationHarness<DB> for C
where DB: Backend, C: Connection<Backend = DB> + MigrationConnection + 'static, <<table as SelectDsl<version>>::Output as OrderDsl<Desc<version>>>::Output: LoadQuery<'b, C, MigrationVersion<'static>>, InsertStatement<table, <Grouped<Eq<version, <MigrationVersion<'static> as AsExpression<<version as Expression>::SqlType>>::Expression>> as Insertable<table>>::Values>: for<'a> QueryFragment<DB> + for<'a> ExecuteDsl<C, DB>, DeleteStatement<<<table as FindDsl<MigrationVersion<'static>>>::Output as HasTable>::Table, <<table as FindDsl<MigrationVersion<'static>>>::Output as IntoUpdateTarget>::WhereClause>: ExecuteDsl<C>, str: ToSql<Text, DB>,

§

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

Revert a single migration Read more
§

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

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

Execute all unapplied migrations for a given migration source
§

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

Revert all applied migrations from a given migration source
§

fn revert_last_migration<S>( &mut self, source: S, ) -> Result<MigrationVersion<'static>, Box<dyn Error + Sync + Send>>
where S: MigrationSource<DB>,

Revert the last migration from a given migration source Read more
§

fn pending_migrations<S>( &mut self, source: S, ) -> Result<Vec<Box<dyn Migration<DB>>>, Box<dyn Error + Sync + Send>>
where S: MigrationSource<DB>,

Get a list of non applied migrations for a specific migration source 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

impl<T> MaybeSendSync for T