pub struct CancelToken { /* private fields */ }Expand description
查询取消令牌:记录目标后端 PID,可在另一条连接上取消/终止其当前语句。
关闭连接不会取消它正在执行的查询;只有 pg_cancel_backend(语句级,连接可
继续使用)或 pg_terminate_backend(连接级)会。取消成功后目标语句以
SQLSTATE 57014 结束,映射为 crate::SqlErrorKind::QueryCanceled /
crate::DbErrorCategory::Timeout。
生命周期约束:token 只在目标连接仍被持有时有效。连接一旦归还连接池并被
复用,backend_pid 可能已指向另一个会话,此时用该 token 取消会误伤其他查询。
Implementations§
Source§impl CancelToken
impl CancelToken
Trait Implementations§
Source§impl Clone for CancelToken
impl Clone for CancelToken
Auto Trait Implementations§
impl !RefUnwindSafe for CancelToken
impl !UnwindSafe for CancelToken
impl Forget for CancelToken
impl Freeze for CancelToken
impl Move for CancelToken
impl Send for CancelToken
impl Sync for CancelToken
impl Unpin for CancelToken
impl UnsafeUnpin for CancelToken
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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