Skip to main content

cvkg_cli/
runtime_connection.rs

1//! Runtime Connection Layer
2//! Handles communication between CLI and running app
3
4use tokio::sync::mpsc;
5
6/// Runtime message types
7#[derive(Debug, Clone)]
8pub enum RuntimeMessage {
9    Patch(super::patch_engine::RuntimePatch),
10    State(super::dev_runtime::RuntimeStateSnapshot),
11    Event(super::dev_runtime::RuntimeEvent),
12}
13
14/// Runtime connection handles communication between CLI and running app
15pub struct RuntimeConnection {
16    sender: mpsc::Sender<RuntimeMessage>,
17}
18
19impl RuntimeConnection {
20    /// Create a new RuntimeConnection
21    pub fn new() -> (Self, mpsc::Receiver<RuntimeMessage>) {
22        let (sender, receiver) = mpsc::channel(100);
23        (Self { sender }, receiver)
24    }
25    
26    /// Send a message to the runtime
27    pub async fn send(&self, msg: RuntimeMessage) {
28        let _ = self.sender.send(msg).await;
29    }
30}