use std::fmt;
use crate::Win32Error;
#[cfg(test)]
mod tests;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct LStatus(i32);
impl LStatus {
#[must_use]
pub const fn from_raw(raw: i32) -> Self {
Self(raw)
}
#[must_use]
pub const fn raw(self) -> i32 {
self.0
}
#[must_use]
pub const fn is_success(self) -> bool {
self.to_win32().is_success()
}
pub const fn into_result(self) -> Result<(), Win32Error> {
self.to_win32().into_result()
}
#[must_use]
pub const fn to_win32(self) -> Win32Error {
Win32Error::from_code(self.0.cast_unsigned())
}
}
impl Win32Error {
#[must_use]
pub const fn to_lstatus(self) -> LStatus {
LStatus::from_raw(self.code().cast_signed())
}
}
impl From<LStatus> for Win32Error {
fn from(status: LStatus) -> Self {
status.to_win32()
}
}
impl From<Win32Error> for LStatus {
fn from(error: Win32Error) -> Self {
error.to_lstatus()
}
}
impl fmt::Display for LStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.to_win32(), f)
}
}