use std::io::Result;
#[cfg(unix)]
pub mod unix;
#[cfg(windows)]
pub mod windows;
pub trait Process: Sized {
type Command;
type Stream;
fn spawn<S>(cmd: S) -> Result<Self>
where
S: AsRef<str>;
fn spawn_command(command: Self::Command) -> Result<Self>;
fn open_stream(&mut self) -> Result<Self::Stream>;
}
#[allow(clippy::wrong_self_convention)]
pub trait Healthcheck {
type Status;
fn get_status(&self) -> Result<Self::Status>;
fn is_alive(&self) -> Result<bool>;
}
impl<T> Healthcheck for &T
where
T: Healthcheck,
{
type Status = T::Status;
fn get_status(&self) -> Result<Self::Status> {
T::get_status(self)
}
fn is_alive(&self) -> Result<bool> {
T::is_alive(self)
}
}
impl<T> Healthcheck for &mut T
where
T: Healthcheck,
{
type Status = T::Status;
fn get_status(&self) -> Result<Self::Status> {
T::get_status(self)
}
fn is_alive(&self) -> Result<bool> {
T::is_alive(self)
}
}
pub trait NonBlocking {
fn set_blocking(&mut self, on: bool) -> Result<()>;
}
impl<T> NonBlocking for &mut T
where
T: NonBlocking,
{
fn set_blocking(&mut self, on: bool) -> Result<()> {
T::set_blocking(self, on)
}
}
pub trait Termios {
fn is_echo(&self) -> Result<bool>;
fn set_echo(&mut self, on: bool) -> Result<bool>;
}
impl<T> Termios for &mut T
where
T: Termios,
{
fn is_echo(&self) -> Result<bool> {
T::is_echo(self)
}
fn set_echo(&mut self, on: bool) -> Result<bool> {
T::set_echo(self, on)
}
}
#[cfg(feature = "async")]
pub trait IntoAsyncStream {
type AsyncStream;
fn into_async_stream(self) -> Result<Self::AsyncStream>;
}