pub struct AnyConnection { /* private fields */ }Expand description
后端无关的连接
Implementations§
Source§impl AnyConnection
impl AnyConnection
Sourcepub fn backend(&self) -> AnyBackend
pub fn backend(&self) -> AnyBackend
获取后端类型
Trait Implementations§
Source§impl Connection for AnyConnection
impl Connection for AnyConnection
Source§fn execute<'a>(
&'a mut self,
sql: &'a str,
) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
fn execute<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
执行 SQL(INSERT/UPDATE/DELETE),返回影响行数
Source§fn query<'a>(
&'a mut self,
sql: &'a str,
) -> Pin<Box<dyn Future<Output = Result<QueryRows, DbError>> + Send + 'a>>
fn query<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Future<Output = Result<QueryRows, DbError>> + Send + 'a>>
执行查询(SELECT),返回结果行集
Source§fn begin_transaction<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
fn begin_transaction<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
开启事务
Source§fn commit<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
fn commit<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
提交事务
Source§fn rollback<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
fn rollback<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
回滚事务
Source§fn in_transaction(&self) -> bool
fn in_transaction(&self) -> bool
连接是否处于未提交事务中 Read more
Source§fn session_reset_sql(&self) -> Option<&'static str>
fn session_reset_sql(&self) -> Option<&'static str>
归还连接时用于复位会话状态的 SQL 语句(
None = 该适配器无复位语句) Read moreSource§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
判断连接是否仍然有效
Source§fn close<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
fn close<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<(), DbError>> + Send + 'a>>
关闭连接
Source§fn execute_with_params<'a>(
&'a mut self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
fn execute_with_params<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
参数绑定执行(INSERT/UPDATE/DELETE) Read more
Source§fn query_with_params<'a>(
&'a mut self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<QueryRows, DbError>> + Send + 'a>>
fn query_with_params<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<QueryRows, DbError>> + Send + 'a>>
参数绑定查询(SELECT) Read more
Source§fn query_values<'a>(
&'a mut self,
sql: &'a str,
) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
fn query_values<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
位置式查询(SELECT):返回
(列名, 按列顺序的值矩阵) Read moreSource§fn query_values_with_params<'a>(
&'a mut self,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
fn query_values_with_params<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<QueryValues, DbError>> + Send + 'a>>
参数绑定位置式查询(SELECT):叠加 prepared statement + 位置式映射双重优化 Read more
Source§fn query_stream<'a>(
&'a mut self,
sql: &'a str,
) -> Pin<Box<dyn Stream<Item = QueryStreamItem> + Send + 'a>>
fn query_stream<'a>( &'a mut self, sql: &'a str, ) -> Pin<Box<dyn Stream<Item = QueryStreamItem> + Send + 'a>>
流式查询:返回逐行结果流 Read more
Source§fn query_stream_cursor<'a>(
&'a mut self,
sql: &'a str,
batch_size: usize,
) -> Pin<Box<dyn Stream<Item = QueryStreamItem> + Send + 'a>>
fn query_stream_cursor<'a>( &'a mut self, sql: &'a str, batch_size: usize, ) -> Pin<Box<dyn Stream<Item = QueryStreamItem> + Send + 'a>>
游标式流式查询(P1-2):按
batch_size 分批拉取,避免大结果集内存峰值。 Read moreSource§fn execute_batch<'a>(
&'a mut self,
sqls: &'a [String],
) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
fn execute_batch<'a>( &'a mut self, sqls: &'a [String], ) -> Pin<Box<dyn Future<Output = Result<u64, DbError>> + Send + 'a>>
批量执行多条 SQL(按顺序执行,返回累计影响行数) Read more
Source§fn take_session_dirty(&mut self) -> bool
fn take_session_dirty(&mut self) -> bool
Source§fn mark_session_clean(&mut self)
fn mark_session_clean(&mut self)
复位语句执行成功后由池调用:清除脏标记。
注意复位 SQL 本身是
SET ...,实现方的执行路径会再次置脏,
必须依赖本方法统一复位。Auto Trait Implementations§
impl !RefUnwindSafe for AnyConnection
impl !UnwindSafe for AnyConnection
impl Forget for AnyConnection
impl Freeze for AnyConnection
impl Send for AnyConnection
impl Sync for AnyConnection
impl Unpin for AnyConnection
impl UnsafeUnpin for AnyConnection
Blanket Implementations§
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<C> ConnectionExt for Cwhere
C: Connection + ?Sized,
impl<C> ConnectionExt for Cwhere
C: Connection + ?Sized,
Source§fn prepare_cached<'a>(
&'a mut self,
cache: &'a PreparedStatementCache,
sql: &'a str,
params: &'a [Value],
) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, DbError>> + Send + 'a>>
fn prepare_cached<'a>( &'a mut self, cache: &'a PreparedStatementCache, sql: &'a str, params: &'a [Value], ) -> Pin<Box<dyn Future<Output = Result<Vec<HashMap<String, Value>>, DbError>> + Send + 'a>>
PreparedStatement 句柄复用查询 Read more
Source§fn query_stream_unified<'a>(
&'a mut self,
sql: &'a str,
batch_size: usize,
) -> Result<Box<dyn AsyncRowStream + 'a>, DbError>
fn query_stream_unified<'a>( &'a mut self, sql: &'a str, batch_size: usize, ) -> Result<Box<dyn AsyncRowStream + 'a>, DbError>
统一流式结果集 Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more