pub struct PoisonGuard<'a> { /* private fields */ }Expand description
A RAII guard that marks a connection as poisoned if dropped before disarmed.
This is a structural guarantee that protects protocol integrity when async operations are cancelled (e.g., by timeouts).
§Safety
The guard must live across the entire critical section. Dropping it early or disarming before all I/O completes defeats its purpose.
Implementations§
Source§impl<'a> PoisonGuard<'a>
impl<'a> PoisonGuard<'a>
Sourcepub fn new(flag: &'a mut bool) -> Self
pub fn new(flag: &'a mut bool) -> Self
Create a new guard, immediately marking the connection as poisoned.
The connection will remain poisoned unless disarm() is called.
Sourcepub fn disarm(self)
pub fn disarm(self)
Disarm the guard, marking the connection as healthy.
Only call this when the entire I/O operation has completed successfully.
§Example
let guard = PoisonGuard::new(&mut is_poisoned);
// Perform all I/O operations
// ...
// Only disarm after everything succeeds
guard.disarm();Auto Trait Implementations§
impl<'a> !UnwindSafe for PoisonGuard<'a>
impl<'a> Freeze for PoisonGuard<'a>
impl<'a> RefUnwindSafe for PoisonGuard<'a>
impl<'a> Send for PoisonGuard<'a>
impl<'a> Sync for PoisonGuard<'a>
impl<'a> Unpin for PoisonGuard<'a>
impl<'a> UnsafeUnpin for PoisonGuard<'a>
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> 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