OrchFlow Mux
Terminal multiplexer abstraction layer supporting multiple backends including tmux and mock implementations.
Features
- Backend Abstraction: Clean trait-based interface for terminal multiplexers
- Tmux Support: Full tmux integration with session, pane, and window management
- Mock Backend: Testing and development backend with configurable behavior
- Factory Pattern: Automatic backend selection based on environment
- Async/Await: Fully async API for non-blocking operations
- Error Handling: Comprehensive error types for robust integration
Supported Backends
- TmuxBackend: Production-ready tmux integration
- MockBackend: Testing and development backend
- Future: Screen, custom multiplexers
Usage
Basic Usage
use ;
use BackendFactory;
async
Direct Backend Usage
use ;
// Create tmux backend directly
let backend = new;
// Session management
let session_id = backend.create_session.await?;
let sessions = backend.list_sessions.await?;
// Pane operations
let pane_id = backend.create_pane.await?;
backend.resize_pane.await?;
backend.select_pane.await?;
// Terminal interaction
backend.send_keys.await?;
backend.send_keys.await?;
// Cleanup
backend.kill_pane.await?;
backend.kill_session.await?;
Mock Backend for Testing
use ;
// Create mock backend
let mut backend = new;
// Configure mock behavior
backend.set_fail_mode;
backend.set_custom_output;
// Use like any other backend
let session_id = backend.create_session.await?;
let pane_id = backend.create_pane.await?;
// Mock will return configured output
let output = backend.capture_pane.await?;
assert_eq!;
Environment-Based Backend Selection
use BackendFactory;
// Set environment variable to control backend
set_var;
// Factory will create appropriate backend
let backend = create_backend.await?;
// Works with any backend implementation
let session_id = backend.create_session.await?;
Backend Trait
Implement MuxBackend
for custom multiplexer support:
use ;
use async_trait;
;
Error Handling
The crate provides comprehensive error types:
use MuxError;
match backend.create_session.await
Integration with OrchFlow Core
This crate is designed to work seamlessly with orchflow-core
:
use ;
use BackendFactory;
use Arc;
let store = new;
let state_manager = new;
let backend = new;
let manager = new;
License
Licensed under either of
- Apache License, Version 2.0
- MIT license
at your option.