dscode_terminal/lib.rs
1//! # dscode-terminal
2//!
3//! Terminal manager and PTY lifecycle management for DSCode.
4//!
5//! This crate provides a portable PTY-backed terminal manager that can be used
6
7#![warn(missing_docs)]
8#![deny(rustdoc::broken_intra_doc_links)]
9#![warn(dead_code)]
10//! independently of any UI framework. Event forwarding is abstracted behind the
11//! [`TerminalEventSender`] trait, with an optional Tauri implementation gated
12//! behind the `tauri` feature flag.
13//!
14//! ## Feature Flags
15//!
16//! - **tauri** — Enables [`TauriEventSender`], a [`TerminalEventSender`]
17//! implementation that forwards PTY output and close events to a Tauri
18//! frontend via the Tauri event system.
19
20mod error;
21mod manager;
22
23pub use error::TerminalError;
24pub use manager::{
25 TerminalInfo, TerminalInstance, TerminalManager, TerminalOptions, TerminalProfile, TerminalState,
26};
27
28/// Trait abstracting how terminal events are forwarded to a consumer.
29///
30/// Implement this trait to integrate the terminal manager with your preferred
31/// UI or event system. The crate ships a Tauri-based implementation behind the
32/// `tauri` feature flag.
33pub trait TerminalEventSender: Send + Sync {
34 /// Forward PTY output data for the given terminal.
35 fn send_output(&self, terminal_id: &str, data: &str);
36
37 /// Signal that the terminal with the given ID has closed.
38 fn send_close(&self, terminal_id: &str);
39}
40
41// ── Tauri integration ──────────────────────────────────────────────────────
42
43#[cfg(feature = "tauri")]
44mod tauri_sender;
45
46#[cfg(feature = "tauri")]
47pub use tauri_sender::TauriEventSender;