use tokio::sync::mpsc;
use crate::debug::{DebugCapture, DebugEvent};
use crate::observe::{Observation, Observer};
pub(crate) const SIDE_CHANNEL_CAPACITY: usize = 256;
pub(crate) struct ProxyObserver {
pub(crate) tx: mpsc::Sender<(String, Observation)>,
}
impl Observer for ProxyObserver {
fn observe(&self, _execution: &str, section: &str, event: Observation) {
let _ = self.tx.try_send((section.to_owned(), event));
}
}
pub(crate) struct DebugMsg {
pub(crate) section: String,
pub(crate) turn_index: u32,
pub(crate) event: DebugEvent,
}
pub(crate) struct ProxyDebugCapture {
pub(crate) tx: mpsc::Sender<DebugMsg>,
}
impl DebugCapture for ProxyDebugCapture {
fn on_event(&self, _execution: &str, section: &str, turn_index: u32, event: DebugEvent) {
let _ = self.tx.try_send(DebugMsg {
section: section.to_owned(),
turn_index,
event,
});
}
}