Trait CheckNumberError

Source
pub trait CheckNumberError
where Self: Zero + Sized,
{ // Required methods fn nonzero_with_win32_or_err(self) -> Result<Self>; fn nonzero_or_win32_err(self) -> Result<Self>; fn nonzero_or_e_fail(self) -> Result<Self>; }

Required Methods§

Source

fn nonzero_with_win32_or_err(self) -> Result<Self>

Passes a non-zero self through to an Ok value, or, in case of it being zero, returns Err with windows::core::Error::from_win32(), if it yields an error code, or Ok(0) otherwise.

To be used with functions that communicate valid values as well as errors by a return value of 0 and need an additional call to GetLastError() to check whether an error has occurred (e.g., SetWindowLongPtrW()). Note that, depending on whether the function calls SetLastError() under all circumstances, you may need to precede the call for which you call this function by SetLastError(ERROR_SUCCESS).

Source

fn nonzero_or_win32_err(self) -> Result<Self>

Passes a non-zero self through to an Ok value, or, in case of it being zero, returns Err with windows::core::Error::from_win32().

Source

fn nonzero_or_e_fail(self) -> Result<Self>

Passes a non-zero self through to an Ok value, or, in case of it being zero, returns Err with HRESULT E_FAIL.

To be used with functions that don’t offer an error code via GetLastError().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> CheckNumberError for T
where T: Zero,