Skip to main content

ErrorModeGuard

Struct ErrorModeGuard 

Source
pub struct ErrorModeGuard { /* private fields */ }
Expand description

Holds an installed error mode until it is released.

§Release explicitly on the ordinary path

release reports whether the thread was actually restored. Dropping the guard instead restores on a best-effort basis and discards any failure, because a destructor has no caller to report to. That is the right behaviour while unwinding, where no report could be delivered anyway, and the wrong behaviour on the ordinary path – so the ordinary path calls release.

Restoration failure is not fatal here. Contrast impersonation, whose restore failure is fail-fast because returning a shared worker under an unknown identity is a process-wide security failure; leaving a thread with the wrong error mode is a real contamination but not that, and imposing the strictest aspect’s semantics on every aspect is precisely what this crate’s composite exists to avoid.

Implementations§

Source§

impl ErrorModeGuard

Source

pub const fn previous(&self) -> Result<ThreadErrorMode, UnsupportedBits>

The mode this thread had before the guard was installed.

§Errors

Returns UnsupportedBits in the same unreachable-by-measurement case as ThreadErrorMode::capture. The guard itself keeps the raw value, so restoration round-trips exactly whatever Windows reported, whether or not this crate’s type can name it.

Source

pub fn release(self) -> Result<(), RestoreError>

Restore the thread’s entry mode, reporting whether it worked.

§Errors

Returns RestoreError if Windows refused, leaving the thread contaminated with whatever was installed.

Trait Implementations§

Source§

impl Debug for ErrorModeGuard

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for ErrorModeGuard

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.