#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("failed to open PTY: {source}")]
OpenPtyFailed {
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("failed to disable PTY echo: {source}")]
DisableEchoFailed {
#[source]
source: std::io::Error,
},
#[error("Builder has no command set")]
MissingCommand,
#[error("failed to spawn command in PTY: {source}")]
SpawnCommandFailed {
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("failed to clone PTY reader: {source}")]
CloneReaderFailed {
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("failed to take PTY writer: {source}")]
TakeWriterFailed {
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("failed to spawn thread '{name}': {source}")]
ThreadSpawn {
name: &'static str,
#[source]
source: std::io::Error,
},
#[error("send failed: child stdin closed")]
SendClosed,
#[error("send failed: writer queue is full")]
SendQueueFull,
#[error("blocking send from inside a tokio runtime; use the async variant")]
BlockingInsideAsync,
#[error("invalid resize dimensions: rows={rows}, cols={cols}")]
InvalidResize {
rows: u16,
cols: u16,
},
#[error("failed to resize PTY to {rows}x{cols}: {source}")]
ResizeFailed {
rows: u16,
cols: u16,
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("failed to receive child exit status")]
ExitStatusUnavailable,
#[error("failed to terminate process group: {source}")]
TerminateFailed {
#[source]
source: std::io::Error,
},
#[error("failed to force-kill process group: {source}")]
ForceKillFailed {
#[source]
source: std::io::Error,
},
#[error(transparent)]
Core(#[from] tastty_core::Error),
}
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
#[error("PTY reader thread failed: {source}")]
#[non_exhaustive]
pub struct ReaderError {
pub kind: std::io::ErrorKind,
#[source]
pub source: std::io::Error,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum WriterOperation {
Write,
Flush,
}
impl std::fmt::Display for WriterOperation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Write => f.write_str("write"),
Self::Flush => f.write_str("flush"),
}
}
}
#[derive(Debug, thiserror::Error)]
#[error("PTY writer thread failed during {operation}: {source}")]
#[non_exhaustive]
pub struct WriterError {
pub operation: WriterOperation,
pub kind: std::io::ErrorKind,
#[source]
pub source: std::io::Error,
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum IoError {
#[error(transparent)]
Reader(#[from] ReaderError),
#[error(transparent)]
Writer(#[from] WriterError),
}
pub type IoErrorReceiver = tokio::sync::mpsc::UnboundedReceiver<IoError>;