| Crates.io | rdx-hyperclock |
| lib.rs | rdx-hyperclock |
| version | 0.3.1 |
| created_at | 2025-08-01 23:55:54.101092+00 |
| updated_at | 2025-08-01 23:57:49.852843+00 |
| description | A high-performance, event-driven, phased time simulation engine. |
| homepage | |
| repository | https://github.com/rustadex/hyperclock |
| max_upload_size | |
| id | 1777861 |
| size | 89,805 |
A high-performance, event-driven, phased time engine for Rust, designed for simulations, game development, and complex, time-sensitive applications.
Hyperclock is a library for building complex, time-sensitive, and event-driven applications in Rust. It provides a powerful "phasetime" engine that acts as the central nervous system for your project, allowing you to schedule logic, react to events, and manage complex automations with a clean, decoupled architecture.
It's designed for applications that need to manage a lot of concurrent logic that happens over time, such as:
Low, Medium, High, Ultra).tokio and thread-safe primitives (Arc, RwLock, SlotMap) to ensure your application is robust and free from data races.hypershell, a fully interactive command-line application for live testing and interaction with a running Hyperclock engine.The fastest way to experience Hyperclock is to run the hypershell.
Clone the repository:
git clone https://github.com/your-username/hyperclock-project.git
cd hyperclock-project
Run hypershell:
The -p flag tells Cargo to run the rdx-hypershell package from within the workspace.
cargo run -p rdx-hypershell
Once running, you can interact with the live engine.
# The shell starts up with the banner and prompt
>>
# Add a task that will fire every 3 seconds
>> add interval 3
--> Added interval listener with handle: #0
<-- [SYSTEM EVENT] ListenerAdded { id: ListenerId(0v1) }
>>
# See the list of active listeners
>> list
Active Listeners:
Handle #0: ListenerId(0v1)
>>
# After 3 seconds, the background engine fires the task!
<-- [INTERVAL TASK] A 3-second interval fired!
# Remove the listener using its handle
>> remove interval 0
--> Listener successfully removed.
<-- [SYSTEM EVENT] ListenerRemoved { id: ListenerId(0v1) }
>>
# The task will no longer fire. Now exit the shell.
>> exit
Exiting hypershell...
# The engine shuts down gracefully
INFO [Hyper Engine] has shut down.
To use Hyperclock in your own project, add rdx-hyperclock as a dependency.
Here's how to initialize and run the engine in your own main.rs.
use rdx_hyperclock::prelude::*;
use std::time::Duration;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
// 1. Create a configuration for the engine.
let config = HyperclockConfig {
resolution: ClockResolution::High, // 60 ticks per second
..Default::default()
};
// 2. Create the engine instance.
let engine = HyperclockEngine::new(config);
// 3. Register your application's logic.
engine.on_interval(
PhaseId(0),
Duration::from_secs(1),
|| println!("One second has passed!")
).await;
// 4. Run the engine. This is a blocking call.
engine.run().await?;
Ok(())
}
The engine's behavior can be configured via a TOML file. You would create a config.toml file and load it using the config crate in your application.
Example config.toml:
# Set the master clock to run at 120 ticks per second.
resolution = "ultra"
# Define a 3-phase cycle for our game loop.
[[phases]]
id = 0
label = "input_processing"
[[phases]]
id = 1
label = "game_logic_and_physics"
[[phases]]
id = 2
label = "render_prep"
Hyperclock is under active development. Key features planned for the future include:
Hyperclock & Hypershell are part of the Rustadex (RDX) Codex. Library of Rust-based tools and parts for general junkyard engineering. Build a rocket.
Contributions are welcome! Please feel free to open an issue or submit a pull request.
This project is dual-licensed under the terms of both the MIT license and the Apache License, Version 2.0.