#[cfg(feature = "pipe")]
#[cfg_attr(docsrs, doc(cfg(feature = "pipe")))]
pub mod pipe;
#[cfg(feature = "async-pipe")]
#[cfg_attr(docsrs, doc(cfg(feature = "async-pipe")))]
pub mod async_pipe;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[cfg(any(feature = "pipe", feature = "async-pipe"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "pipe", feature = "async-pipe"))))]
pub enum PipeError {
Closed,
Eof,
}
impl PipeError {
#[inline]
pub const fn is_eof(&self) -> bool {
matches!(self, Self::Eof)
}
#[inline]
pub const fn is_closed(&self) -> bool {
matches!(self, Self::Closed)
}
}
impl core::fmt::Display for PipeError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
PipeError::Closed => write!(f, "Pipe: read/write on closed pipe"),
PipeError::Eof => write!(f, "Pipe: EOF"),
}
}
}
impl std::error::Error for PipeError {}
pub trait ReadWriter: std::io::Write + std::io::Read {}
impl<T: std::io::Read + std::io::Write> ReadWriter for T {}
pub trait ReadCloser: std::io::Read + Closer {}
impl<T: std::io::Read + Closer> ReadCloser for T {}
pub trait WriteCloser: std::io::Write + Closer {}
impl<T: std::io::Write + Closer> WriteCloser for T {}
pub trait ReadWriteCloser: std::io::Read + Closer {}
pub trait Closer {
fn close(&mut self) -> std::io::Result<()>;
}