use super::{InputChannel, OutputChannel};
use crate::vm::alpha::RuntimeAlpha;
use std::fmt::{Debug, Formatter};
pub(in super::super) type InputChannelObj = Box<dyn InputChannel>;
pub(in super::super) type OutputChannelObj = Box<dyn OutputChannel>;
#[derive(Default)]
pub(in super::super) struct ReasonerChannels {
pub input_channels: Vec<InputChannelObj>,
pub output_channels: Vec<OutputChannelObj>,
}
impl ReasonerChannels {
pub(in super::super) fn new() -> Self {
Self::default()
}
pub fn add_input_channel(&mut self, channel: InputChannelObj) {
self.input_channels.push(channel);
}
pub fn add_output_channel(&mut self, channel: OutputChannelObj) {
self.output_channels.push(channel);
}
}
impl Debug for ReasonerChannels {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ReasonerChannels")
.field(
"input_channels",
&format!("[Box<dyn InputChannel>; {}]", self.input_channels.len()),
)
.field(
"output_channels",
&format!("[Box<dyn OutputChannel>; {}]", self.output_channels.len()),
)
.finish()
}
}
impl RuntimeAlpha {
pub fn add_input_channel(&mut self, channel: InputChannelObj) {
self.io_channels.add_input_channel(channel);
}
pub fn add_output_channel(&mut self, channel: OutputChannelObj) {
self.io_channels.add_output_channel(channel);
}
}