orchflow_terminal/
ipc_trait.rs1use crate::protocol::{ControlMessage, TerminalInput};
6use crate::pty_manager::PtyHandle;
7use async_trait::async_trait;
8
9#[async_trait]
11pub trait IpcChannel: Send + Sync {
12 async fn start_streaming(
14 &self,
15 terminal_id: String,
16 pty_handle: PtyHandle,
17 ) -> Result<(), Box<dyn std::error::Error>>;
18
19 async fn send_input(
21 &self,
22 terminal_id: &str,
23 input: TerminalInput,
24 ) -> Result<(), Box<dyn std::error::Error>>;
25
26 async fn send_control(
28 &self,
29 terminal_id: &str,
30 message: ControlMessage,
31 ) -> Result<(), Box<dyn std::error::Error>>;
32
33 async fn stop_streaming(&self, terminal_id: &str) -> Result<(), Box<dyn std::error::Error>>;
35}
36
37pub struct DirectChannel;
39
40#[async_trait]
41impl IpcChannel for DirectChannel {
42 async fn start_streaming(
43 &self,
44 _terminal_id: String,
45 _pty_handle: PtyHandle,
46 ) -> Result<(), Box<dyn std::error::Error>> {
47 Ok(())
49 }
50
51 async fn send_input(
52 &self,
53 _terminal_id: &str,
54 _input: TerminalInput,
55 ) -> Result<(), Box<dyn std::error::Error>> {
56 Ok(())
58 }
59
60 async fn send_control(
61 &self,
62 _terminal_id: &str,
63 _message: ControlMessage,
64 ) -> Result<(), Box<dyn std::error::Error>> {
65 Ok(())
67 }
68
69 async fn stop_streaming(&self, _terminal_id: &str) -> Result<(), Box<dyn std::error::Error>> {
70 Ok(())
72 }
73}