| Crates.io | zellij-runtime |
| lib.rs | zellij-runtime |
| version | 0.0.4 |
| created_at | 2025-10-09 17:26:48.057195+00 |
| updated_at | 2025-10-13 18:48:02.401322+00 |
| description | An async runtime for zellij plugins |
| homepage | |
| repository | https://github.com/Borwe/zellij_runtime/ |
| max_upload_size | |
| id | 1875963 |
| size | 125,744 |
Zellij PluginsThis crate provides to way to have async rust capabilities while inside a zellij plugin for plugin developers, it is 3rd party and therefore not officially directly associated by the zellij team.
This isn't using tokio, or async-std, it's a custom runtime specifically for zellij, if intending to use crates you might have to provide your own reactor with them, or extend this crates reactor to support those crates.
For starters all the functions for usage for async functionality are in the zellij_runtime::prelude::*
space, but you can explore others exported by the crate, be careful though, read the docs to what they do
and post an issue on the repo if not clear, or if you have suggestions for making it more clear.
Before function start properly, you'll need to initialize the plugin state with
zellij_runtim::prelude::register_async_plugin macro instead of as you would have
before with register_plugin macro from the zellij_tile crate used for plugin.
To first create an async task call zellij_runtime::prelude::spawn as shown bellow:
/// Spawn a new async activity.
/// If None is passed as @id parameter then it will be
/// spawned everytime the call comes as a unique async task.
/// If you want to only spawn it once, then give it a single id,
/// by calling the function zellij_runtime::prelude::get_id(),
/// which returns a unique id, and means that runtime will check if a task
/// with such an id exists or not, if it does then the task is added to the queue
/// else nothing happens, even if the _this_ get's called over and over with
/// the same @id value eg:
self.id = get_id();
spawn(self.id, async {
for i in 0..10 {
eprintln!("YO-{i}");
sleep(Duration::from_secs(5)).await;
}
});
/// remember to cache the id from get_id() to some state, otherwise just calling get_id(),
/// and passing it directly will be the same as passing None, as you will be passing a new
/// id everytime.
This function creates an async task and stores it to be made progress evertime the update function
get's called, that is when the reactor also wakes up sleeping tasks too.
zellij_runtime::prelude::spawnClone trait