#[cfg(feature = "pty")]
pub mod pty;
use futures_channel::mpsc::UnboundedSender;
use crate::handle::TerminalError;
pub trait TerminalBackend {
fn start(&mut self, output: TerminalOutput) -> Result<(), TerminalError>;
fn write(&mut self, data: &[u8]) -> Result<(), TerminalError>;
fn resize(&mut self, rows: u16, cols: u16);
}
#[derive(Clone)]
pub struct TerminalOutput {
pub(crate) sender: UnboundedSender<Vec<u8>>,
}
impl TerminalOutput {
pub fn write(&self, data: impl Into<Vec<u8>>) -> Result<(), TerminalError> {
self.sender
.unbounded_send(data.into())
.map_err(|_| TerminalError::Closed)
}
}