Skip to main content

PoisonGuard

Struct PoisonGuard 

Source
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>

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more