hojicha-runtime

Crates.iohojicha-runtime
lib.rshojicha-runtime
version0.2.2
created_at2025-08-11 19:18:00.591479+00
updated_at2025-08-29 17:13:00.377072+00
descriptionEvent handling and async runtime for Hojicha TUI framework
homepagehttps://jgok76.gitea.cloud/femtomc/hojicha
repositoryhttps://jgok76.gitea.cloud/femtomc/hojicha
max_upload_size
id1790707
size308,376
McCoy R. Becker (femtomc)

documentation

https://docs.rs/hojicha-runtime

README

hojicha-runtime

Event loop and async runtime for the Hojicha TUI framework.

Purpose

This crate provides the runtime engine that powers Hojicha applications:

  • Main event loop with priority-based event processing
  • Async task management and cancellation
  • Terminal handling and panic recovery
  • Resource limits and backpressure control
  • Stream subscriptions for external events

Basic Usage

use hojicha_runtime::Program;
use hojicha_core::Model;

// Assuming you have a Model implementation
struct MyApp { /* ... */ }
impl Model for MyApp { /* ... */ }

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Install panic handler for clean terminal restoration
    hojicha_runtime::panic_handler::install();
    
    // Create and run your application
    let app = MyApp::new();
    let mut program = Program::new(app)?;
    program.run().await?;
    
    Ok(())
}

Key Features

Async Event Handling

  • External events: Send events from other threads via init_async_bridge()
  • Stream subscriptions: Connect any futures::Stream with subscribe()
  • Cancellable tasks: Spawn with automatic cancellation via spawn_cancellable()
  • Resource limits: Prevent resource exhaustion with configurable limits

Panic Recovery

The runtime includes panic recovery to restore the terminal on application panic.

Testing Support

Test harness utilities for behavioral testing.

Documentation

For full documentation and more examples, see the main Hojicha documentation.

License

GPL-3.0 - See LICENSE file for details

Commit count: 0

cargo fmt