Expand description
I/O abstraction for Human interaction.
This module provides the View layer abstraction for ORCS, enabling pluggable I/O backends (Console, WebSocket, etc.).
§Architecture
┌─────────────────────────────────────────────────────────────────┐
│ View Layer │
│ Console, WebSocket, GUI, etc. │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ IOInputHandle │ │ IOOutputHandle │ │
│ │ (send input) │ │ (receive output)│ │
│ └────────┬────────┘ └────────▲────────┘ │
└───────────┼────────────────────────────────┼────────────────────┘
│ IOInput │ IOOutput
▼ │
┌───────────────────────────────────────────────────────────────┐
│ Bridge Layer │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ IOPort │ │
│ │ input_rx ◄── IOInput │ │
│ │ output_tx ──► IOOutput │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ IOBridge (Bridge) │
│ │ │
│ Signal / Request │
└───────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────┐
│ Model Layer │
│ EventBus │
└───────────────────────────────────────────────────────────────┘§Module Structure
types- IO types (IOInput,IOOutput,OutputStyle)port- IO port and handles (IOPort,IOInputHandle,IOOutputHandle)input- Input commands (InputCommand)parser- Input parsing (InputParser)console- Console I/O (Console,ConsoleInputReader)renderer- Console rendering (ConsoleRenderer)
§Example
use orcs_runtime::io::{IOPort, IOInput, IOOutput, OutputStyle};
use orcs_types::ChannelId;
// Create IO port
let channel_id = ChannelId::new();
let (port, input_handle, output_handle) = IOPort::with_defaults(channel_id);
// View layer uses handles
// Bridge layer (IOBridge) uses portStructs§
- Console
- Complete console I/O facade.
- Console
Input Reader - Console input reader.
- Console
Renderer - Console renderer for terminal output.
- IOInput
Handle - Handle for View layer to send input to Bridge layer.
- IOOutput
Handle - Handle for View layer to receive output from Bridge layer.
- IOPort
- IO Port for Bridge layer.
- Input
Context - Context attached to input by the View layer.
- Input
Parser - Stateless input parser.
Enums§
- IOInput
- Input from View layer to Bridge layer.
- IOOutput
- Output from Bridge layer to View layer.
- Input
Command - Parsed input command from Human.
- Output
Style - Output style for text display.
Constants§
- DEFAULT_
BUFFER_ SIZE - Default buffer size for IO channels.
Functions§
- setup_
ctrlc_ handler - Ctrl+C handler that sends Veto signal.