hojicha_runtime/
lib.rs

1//! # Hojicha Runtime
2//!
3//! Event handling and async runtime for Hojicha TUI applications.
4//!
5//! This crate provides the runtime infrastructure for handling events,
6//! managing async operations, and running the main application loop.
7//!
8//! ## Core Components
9//!
10//! - **Program**: Main application runtime and event loop
11//! - **Event Processing**: Priority-based event handling with backpressure
12//! - **Async Support**: Tokio-based async command execution
13//! - **Subscriptions**: Stream-based event sources
14//! - **Error Resilience**: Panic recovery and error handling
15//!
16//! ## Features
17//!
18//! - Priority event queue with automatic scaling
19//! - Resilient input handling with panic recovery
20//! - Safe mutex operations that recover from poison
21//! - Metrics and monitoring support
22//! - Terminal management and restoration
23
24#![warn(missing_docs)]
25
26// Note: Event types are in hojicha-core since they're fundamental to the Model trait
27
28// Program and runtime
29pub mod program;
30pub use program::{MouseMode, Program, ProgramOptions};
31
32// Async support
33pub mod async_handle;
34pub mod stream_builders;
35pub mod subscription;
36
37// Event processing infrastructure
38pub mod metrics;
39pub mod priority_queue;
40pub mod queue_scaling;
41
42// Testing utilities
43pub mod safe_priority;
44pub mod testing;
45
46// Error resilience
47pub mod panic_handler;
48pub mod panic_utils;
49pub mod resilient_input;
50pub mod safe_mutex;
51
52// Re-export from core
53pub use hojicha_core::event::{Event, Key, KeyEvent, KeyModifiers, MouseEvent, WindowSize};
54
55// Re-export runtime types
56pub use async_handle::AsyncHandle;
57pub use subscription::Subscription;
58
59// Re-export program components
60pub use program::{
61    CommandExecutor, EventProcessor, EventStats, FpsLimiter, PriorityConfig,
62    PriorityEventProcessor, TerminalConfig, TerminalManager,
63};
64
65/// Prelude for convenient imports
66/// 
67/// This module provides the essential runtime types for Hojicha applications.
68/// Import everything with:
69/// 
70/// ```
71/// use hojicha_runtime::prelude::*;
72/// ```
73/// 
74/// ## Included Items
75/// 
76/// ### Program & Configuration
77/// - [`Program`] - The main application runtime
78/// - [`ProgramOptions`] - Configuration for the program
79/// - [`MouseMode`] - Mouse tracking options
80/// 
81/// ### Async Support
82/// - [`AsyncHandle`] - Handle for cancellable async operations
83/// - [`Subscription`] - Stream subscription handle
84/// 
85/// ### Stream Builders
86/// - [`interval_stream()`] - Create periodic event streams
87/// - [`timeout_stream()`] - Create timeout streams
88/// - [`delayed_stream()`] - Create delayed streams
89pub mod prelude {
90    // Program and configuration
91    pub use crate::program::{MouseMode, Program, ProgramOptions};
92    
93    // Async support
94    pub use crate::async_handle::AsyncHandle;
95    pub use crate::subscription::Subscription;
96    
97    // Stream builders for common patterns
98    pub use crate::stream_builders::{delayed_stream, interval_stream, timeout_stream};
99    
100    // Re-export essential event types from core
101    pub use hojicha_core::event::{Event, Key, KeyEvent, KeyModifiers, MouseEvent, WindowSize};
102}