mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
feat(core): add (minimal) Executor
This commit is contained in:
parent
66ceff37b7
commit
76dd78f639
@ -7,8 +7,10 @@ mod close;
|
||||
mod connect;
|
||||
mod connection;
|
||||
mod options;
|
||||
mod executor;
|
||||
pub(crate) mod runtime;
|
||||
|
||||
pub use executor::Executor;
|
||||
pub use acquire::Acquire;
|
||||
pub use close::Close;
|
||||
pub use connect::Connect;
|
||||
|
||||
13
sqlx-core/src/blocking/executor.rs
Normal file
13
sqlx-core/src/blocking/executor.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use crate::Database;
|
||||
|
||||
use super::Runtime;
|
||||
|
||||
pub trait Executor<Rt: Runtime>: crate::Executor<Rt>
|
||||
where
|
||||
Self::Database: Database<Rt>,
|
||||
{
|
||||
fn execute<'x, 'e, 'q>(&'e mut self, sql: &'q str) -> crate::Result<()>
|
||||
where
|
||||
'e: 'x,
|
||||
'q: 'x;
|
||||
}
|
||||
25
sqlx-core/src/executor.rs
Normal file
25
sqlx-core/src/executor.rs
Normal file
@ -0,0 +1,25 @@
|
||||
#[cfg(feature = "async")]
|
||||
use futures_core::future::BoxFuture;
|
||||
|
||||
use crate::{Database, Result, Runtime};
|
||||
|
||||
/// Describes a type that can execute SQL queries on a self-provided database connection.
|
||||
///
|
||||
/// No guarantees are provided that successive queries run on the same physical
|
||||
/// database connection.
|
||||
///
|
||||
/// A [`Connection`] is an `Executor` that guarantees that successive queries are ran on the
|
||||
/// same physical database connection.
|
||||
///
|
||||
pub trait Executor<Rt: Runtime> {
|
||||
type Database: Database<Rt>;
|
||||
|
||||
/// Execute the SQL query and return information about the result, including
|
||||
/// the number of rows affected, if any.
|
||||
#[cfg(feature = "async")]
|
||||
fn execute<'x, 'e, 'q>(&'e mut self, sql: &'q str) -> BoxFuture<'x, Result<()>>
|
||||
where
|
||||
Rt: crate::Async,
|
||||
'e: 'x,
|
||||
'q: 'x;
|
||||
}
|
||||
@ -24,6 +24,7 @@ mod connect;
|
||||
mod connection;
|
||||
mod database;
|
||||
mod error;
|
||||
mod executor;
|
||||
mod options;
|
||||
mod pool;
|
||||
mod runtime;
|
||||
@ -49,6 +50,7 @@ pub use connect::Connect;
|
||||
pub use connection::Connection;
|
||||
pub use database::{Database, HasOutput};
|
||||
pub use error::{DatabaseError, Error, Result};
|
||||
pub use executor::Executor;
|
||||
pub use options::ConnectOptions;
|
||||
pub use pool::Pool;
|
||||
#[cfg(feature = "actix")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user