Single-threaded async runtime.
Two spawn strategies:
spawn_boxed()— Box-allocated. Default. No setup needed.spawn_slab()— Slab-allocated. Pre-allocated, zero-alloc hot path. Requires slab configured via [RuntimeBuilder::slab].
use nexus_async_rt::*;
use nexus_slab::byte::unbounded::Slab;
use nexus_rt::WorldBuilder;
let mut world = WorldBuilder::new().build();
// Simple — Box-allocated tasks, no slab setup
let mut rt = Runtime::new(&mut world);
rt.block_on(async {
spawn_boxed(async { /* Box-allocated */ });
});
// Power user — with slab for hot-path tasks
// SAFETY: single-threaded runtime.
let slab = unsafe { Slab::<256>::with_chunk_capacity(64) };
let mut rt = Runtime::builder(&mut world)
.slab_unbounded(slab)
.build();
rt.block_on(async {
spawn_boxed(async { /* Box-allocated, long-lived */ });
spawn_slab(async { /* slab-allocated, hot path */ });
});