Files
unshell/unshell-leaves/leaf-pty/src/state.rs
T

53 lines
1.4 KiB
Rust
Raw Normal View History

2026-05-28 18:17:01 -06:00
use unshell::protocol::{HookID, unshell_leaf};
use crate::{constants::LEAF_FAKE_PTY, session::PtySession};
/// User-owned state for the generated fake PTY leaf.
///
2026-05-31 12:14:36 -06:00
/// The `unshell_leaf!` template stores sessions and retry queues around this struct.
/// Keeping counters here makes tests and future procedures observe leaf behavior
/// without reaching into generated session storage.
2026-05-28 18:17:01 -06:00
pub struct FakePtyState {
/// Number of sessions that application logic considers active.
pub active_count: usize,
/// Total number of successfully opened sessions.
pub total_opened: u64,
/// Last hook that received stdin EOF.
pub last_stdin_eof_hook: Option<HookID>,
}
impl FakePtyState {
/// Creates a fake PTY state with no active sessions.
pub fn new() -> Self {
Self {
active_count: 0,
total_opened: 0,
last_stdin_eof_hook: None,
}
}
}
impl Default for FakePtyState {
fn default() -> Self {
Self::new()
}
}
2026-05-31 12:14:36 -06:00
unshell_leaf! {
pub leaf FakePtyLeaf for FakePtyState {
id: LEAF_FAKE_PTY,
meta: unshell::protocol::LeafMeta {
name: "Fake PTY Leaf",
identifier: "dev.unshell.v1.pty",
version: "v0",
authors: unshell::alloc::vec!["ASTATIN3"],
},
sessions {
pty: PtySession,
}
procedures {}
}
}