pub struct Terminal {
input_tx: Sender<Vec<u8>>,
output_tx: Sender<Vec<u8>>,
fd: Arc<AsyncFd<OwnedFd>>,
child: Mutex<Option<Child>>,
closed_rx: Receiver<bool>,
}Expand description
Async terminal backed by a real PTY.
Spawns two background tasks (read loop and write loop) that bridge the PTY
fd with tokio channels. Sends SIGHUP to the child process on drop.
Fields§
§input_tx: Sender<Vec<u8>>§output_tx: Sender<Vec<u8>>§fd: Arc<AsyncFd<OwnedFd>>§child: Mutex<Option<Child>>§closed_rx: Receiver<bool>Implementations§
Source§impl Terminal
impl Terminal
Sourcepub fn spawn(
shell: &str,
pwd: Option<&Path>,
) -> Result<(Self, Receiver<Vec<u8>>)>
pub fn spawn( shell: &str, pwd: Option<&Path>, ) -> Result<(Self, Receiver<Vec<u8>>)>
Spawn a shell process and return the terminal plus an initial output receiver.
If pwd is provided, the shell starts in that directory.
Sourcepub fn subscribe(&self) -> Receiver<Vec<u8>>
pub fn subscribe(&self) -> Receiver<Vec<u8>>
Subscribe to the terminal output broadcast channel.
Sourcepub fn closed(&self) -> Receiver<bool>
pub fn closed(&self) -> Receiver<bool>
Returns a watch receiver that becomes true when the PTY read
loop exits (shell died / PTY closed).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Terminal
impl !RefUnwindSafe for Terminal
impl Send for Terminal
impl Sync for Terminal
impl Unpin for Terminal
impl !UnwindSafe for Terminal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more