pub struct CancelToken(/* private fields */);Expand description
A flag a caller can raise to stop a chunked bulk write (0.13.8, W7.6, D-181).
Cheap to clone and safe to set from any thread, which is the whole point: the task running the import is the one thing that cannot cancel it. Hand a clone to whatever can — a signal handler, a UI thread, a timeout task — and it takes effect at the next chunk boundary.
A boundary, not an abort. Nothing rolls back and no in-flight
transaction is interrupted: the loop notices between chunks and stops
sending. The chunks that committed stay committed, and
BulkInterrupted::written says how many
rows those were. That is the same per-chunk boundary
Database::bulk_import already documents, so cancellation adds a reason to
stop and no new failure mode.
Setting it after the last chunk has committed does nothing — a finished write reports success, because it succeeded.
Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Ask the bulk write holding a clone of this token to stop at its next chunk boundary. Idempotent; a token never un-cancels.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether Self::cancel has been called on this token or any clone.
Trait Implementations§
Source§impl Clone for CancelToken
impl Clone for CancelToken
Source§fn clone(&self) -> CancelToken
fn clone(&self) -> CancelToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CancelToken
impl Debug for CancelToken
Source§impl Default for CancelToken
impl Default for CancelToken
Source§fn default() -> CancelToken
fn default() -> CancelToken
Auto Trait Implementations§
impl Freeze for CancelToken
impl RefUnwindSafe for CancelToken
impl Send for CancelToken
impl Sync for CancelToken
impl Unpin for CancelToken
impl UnsafeUnpin for CancelToken
impl UnwindSafe 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request