use {
super::*,
crate::{error::ConversionError, os::windows::winprelude::*},
std::{
fmt::{self, Debug, Display, Formatter},
io,
},
};
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum FromHandleErrorKind {
IsServerCheckFailed,
NoMessageBoundaries,
}
impl FromHandleErrorKind {
const fn msg(self) -> &'static str {
use FromHandleErrorKind::*;
match self {
IsServerCheckFailed => "failed to determine if the pipe is server-side or not",
NoMessageBoundaries => "the pipe does not preserve message boundaries",
}
}
}
impl From<FromHandleErrorKind> for io::Error {
fn from(e: FromHandleErrorKind) -> Self { io::Error::other(e.msg()) }
}
impl Display for FromHandleErrorKind {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.write_str(self.msg()) }
}
pub type FromHandleError = ConversionError<OwnedHandle, FromHandleErrorKind>;
pub type ReuniteError<Rm, Sm> =
crate::error::ReuniteError<RecvPipeStream<Rm>, SendPipeStream<Sm>>;
pub type ReuniteResult<Rm, Sm> = Result<PipeStream<Rm, Sm>, ReuniteError<Rm, Sm>>;