pub struct IOBridge { /* private fields */ }Expand description
IO Bridge - Pure bridge between View and Model layers.
Converts between IO types (IOInput/IOOutput) and internal events (Signal). This is a stateless transformation layer.
Note: IOBridge does not hold a Principal. The Principal is provided
by the owning ClientRunner when
converting input to Signals.
The parser can be injected for testing or customization.
Implementations§
Source§impl IOBridge
impl IOBridge
Sourcepub fn with_parser(io_port: IOPort, parser: InputParser) -> Self
pub fn with_parser(io_port: IOPort, parser: InputParser) -> Self
Creates a new IOBridge with a custom parser.
This allows injecting a custom parser for testing or customization.
Sourcepub fn channel_id(&self) -> ChannelId
pub fn channel_id(&self) -> ChannelId
Returns the channel ID.
Sourcepub fn command_to_signal(
&self,
cmd: &InputCommand,
principal: &Principal,
default_approval_id: Option<&str>,
) -> Option<Signal>
pub fn command_to_signal( &self, cmd: &InputCommand, principal: &Principal, default_approval_id: Option<&str>, ) -> Option<Signal>
Converts an InputCommand to a Signal.
§Arguments
cmd- The parsed input commandprincipal- Principal to use for the signaldefault_approval_id- Fallback approval ID if command has none
Sourcepub fn parse_line_to_signal(
&self,
line: &str,
principal: &Principal,
default_approval_id: Option<&str>,
) -> Option<Signal>
pub fn parse_line_to_signal( &self, line: &str, principal: &Principal, default_approval_id: Option<&str>, ) -> Option<Signal>
Parses a line of input and converts to Signal.
§Arguments
line- Raw input lineprincipal- Principal to use for the signaldefault_approval_id- Fallback approval ID for HIL responses
Sourcepub fn drain_input_to_signals(
&mut self,
principal: &Principal,
) -> (Vec<Signal>, Vec<InputCommand>)
pub fn drain_input_to_signals( &mut self, principal: &Principal, ) -> (Vec<Signal>, Vec<InputCommand>)
Drains all available input and converts to Signals.
Returns a vector of Signals ready to be dispatched to EventBus. Also returns any InputCommands that couldn’t be converted (e.g., Quit, Unknown) for the caller to handle.
Approval IDs are extracted from the input context provided by View layer.
§Arguments
principal- Principal to use for signals
Sourcepub async fn recv_input(
&mut self,
principal: &Principal,
) -> Option<Result<Signal, InputCommand>>
pub async fn recv_input( &mut self, principal: &Principal, ) -> Option<Result<Signal, InputCommand>>
Receives a single input and processes it.
Async version - waits for input.
Approval IDs are extracted from the input context provided by View layer.
§Arguments
principal- Principal to use for signals
§Returns
Some(Ok(signal))- Input converted to signalSome(Err(cmd))- Input is a command that doesn’t map to signalNone- IO port closed
Sourcepub async fn show_processing(
&self,
component: &str,
operation: &str,
) -> Result<(), SendError<IOOutput>>
pub async fn show_processing( &self, component: &str, operation: &str, ) -> Result<(), SendError<IOOutput>>
Displays a processing notification.
Sourcepub async fn show_approval_request(
&self,
request: &ApprovalRequest,
) -> Result<(), SendError<IOOutput>>
pub async fn show_approval_request( &self, request: &ApprovalRequest, ) -> Result<(), SendError<IOOutput>>
Displays an approval request.
Sourcepub async fn show_approved(
&self,
approval_id: &str,
) -> Result<(), SendError<IOOutput>>
pub async fn show_approved( &self, approval_id: &str, ) -> Result<(), SendError<IOOutput>>
Displays approval confirmation.
Sourcepub async fn show_rejected(
&self,
approval_id: &str,
reason: Option<&str>,
) -> Result<(), SendError<IOOutput>>
pub async fn show_rejected( &self, approval_id: &str, reason: Option<&str>, ) -> Result<(), SendError<IOOutput>>
Displays rejection confirmation.
Sourcepub async fn info(&self, message: &str) -> Result<(), SendError<IOOutput>>
pub async fn info(&self, message: &str) -> Result<(), SendError<IOOutput>>
Displays an info message.
Sourcepub async fn warn(&self, message: &str) -> Result<(), SendError<IOOutput>>
pub async fn warn(&self, message: &str) -> Result<(), SendError<IOOutput>>
Displays a warning message.
Sourcepub async fn error(&self, message: &str) -> Result<(), SendError<IOOutput>>
pub async fn error(&self, message: &str) -> Result<(), SendError<IOOutput>>
Displays an error message.
Sourcepub async fn prompt(&self, message: &str) -> Result<(), SendError<IOOutput>>
pub async fn prompt(&self, message: &str) -> Result<(), SendError<IOOutput>>
Displays a prompt message.
Sourcepub fn is_output_closed(&self) -> bool
pub fn is_output_closed(&self) -> bool
Returns true if the output channel is closed.