use crate::WSLVersion;
use thiserror::Error;
use windows_core::HRESULT;
#[derive(Debug, Error)]
#[error("WSLVersion unsupported: current version {current_version}, required version {required_version}")]
pub struct Error {
pub current_version: WSLVersion,
pub required_version: WSLVersion,
}
impl Error {
#[must_use]
#[inline]
pub const fn new(current_version: WSLVersion, required_version: WSLVersion) -> Self {
Self {
current_version,
required_version,
}
}
pub const WSL_E_PLUGIN_REQUIRES_UPDATE: HRESULT =
HRESULT(wslpluginapi_sys::WSL_E_PLUGIN_REQUIRES_UPDATE);
}
impl From<Error> for HRESULT {
#[inline]
fn from(_: Error) -> Self {
Self(Error::WSL_E_PLUGIN_REQUIRES_UPDATE.0)
}
}
impl From<Error> for windows_core::Error {
#[inline]
fn from(value: Error) -> Self {
Self::from(HRESULT::from(value))
}
}
pub type Result<T> = std::result::Result<T, Error>;