1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Runtime-adapter seam: `SessionBackend` trait and supporting input types.
//!
//! Why: the `SessionActor` must remain backend-agnostic so that
//! `StreamJsonBackend` and `TmuxBackend` can be swapped without touching the
//! actor loop. This module defines the trait and its input type; concrete
//! implementations live in the sibling modules.
//! What: [`SessionBackend`] (§3.3 of SPEC-SESSCTL-01) with three async methods
//! (`send`, `recv`, `stop`) and the [`SessionInput`] input type. Concrete
//! backends: [`stream_json::StreamJsonBackend`] and [`tmux::TmuxBackend`].
//! Test: trait has no side-effect-free tests; concrete backends have their own
//! unit tests in `stream_json` and `tmux` sub-modules.
use Result;
use async_trait;
use crateSessionEvent;
/// Input sent to a session backend from the actor.
///
/// Why: the spec §3.3 shows `send(msg: SessionInput)`. In alpha-1 the only
/// meaningful input is a text line (for both stream-JSON stdin and tmux
/// send-keys). The newtype lets later phases add structured variants
/// (e.g. JSON-framed messages for stream-JSON) without changing the trait.
/// What: wraps a UTF-8 string representing the input to send.
/// Test: used by `TmuxBackend::send` and `StreamJsonBackend::send` unit tests.
/// The runtime-adapter seam separating `SessionActor` from execution backends.
///
/// Why: swapping between stream-JSON, tmux, and future backends (tcode) must
/// not require changes to the actor task loop (§3.3 of SPEC-SESSCTL-01). A
/// trait with three async methods is the minimum viable seam.
/// What: `send` delivers input to the backend; `recv` polls for the next batch
/// of events (returns `None` on clean exit); `stop` gracefully drains and
/// terminates. All methods are `async` so backends can await I/O without
/// blocking the actor's `select!` loop.
/// Test: `StreamJsonBackend` and `TmuxBackend` each carry their own unit tests.