Skip to main content

Module io

Module io 

Source
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

§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 port

Structs§

Console
Complete console I/O facade.
ConsoleInputReader
Console input reader.
ConsoleRenderer
Console renderer for terminal output.
IOInputHandle
Handle for View layer to send input to Bridge layer.
IOOutputHandle
Handle for View layer to receive output from Bridge layer.
IOPort
IO Port for Bridge layer.
InputContext
Context attached to input by the View layer.
InputParser
Stateless input parser.

Enums§

IOInput
Input from View layer to Bridge layer.
IOOutput
Output from Bridge layer to View layer.
InputCommand
Parsed input command from Human.
OutputStyle
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.