| Crates.io | hojicha-core |
| lib.rs | hojicha-core |
| version | 0.2.2 |
| created_at | 2025-08-11 19:17:05.883217+00 |
| updated_at | 2025-08-29 17:12:42.373565+00 |
| description | Core Elm Architecture abstractions for terminal UIs in Rust |
| homepage | https://jgok76.gitea.cloud/femtomc/hojicha |
| repository | https://jgok76.gitea.cloud/femtomc/hojicha |
| max_upload_size | |
| id | 1790704 |
| size | 404,407 |
Core abstractions and types for the Hojicha TUI framework implementing The Elm Architecture.
This crate provides the fundamental building blocks for Hojicha applications:
Model trait for application state managementCmd type for side effects and asynchronous operationsEvent enum for all possible events in the systemuse hojicha_core::{Model, Cmd, Event};
#[derive(Debug, Clone)]
enum MyMessage {
Increment,
Decrement,
}
struct MyApp {
counter: i32,
}
impl Model for MyApp {
type Message = MyMessage;
fn init(&mut self) -> Cmd<Self::Message> {
Cmd::noop()
}
fn update(&mut self, event: Event<Self::Message>) -> Cmd<Self::Message> {
match event {
Event::User(MyMessage::Increment) => {
self.counter += 1;
Cmd::noop()
}
Event::User(MyMessage::Decrement) => {
self.counter -= 1;
Cmd::noop()
}
_ => Cmd::noop()
}
}
fn view(&self) -> String {
format!("Counter: {}", self.counter)
}
}
Model: The core trait that all Hojicha applications must implementCmd<M>: Represents side effects and commands to be executedEvent<M>: All possible events (keyboard, mouse, user messages, etc.)For full documentation and more examples, see the main Hojicha documentation.
GPL-3.0 - See LICENSE file for details