os_slab_vault
os_slab_vault is a dependency-free, no_std-first generational slab / object-pool crate designed for Rust operating system kernels and other bare-metal runtimes.
It provides:
- Fixed-capacity storage (
Slab<T, N>) with O(1) insert/remove. - Generation-checked handles (
Key) that detect stale use-after-free. - Allocation-free iteration over live objects.
- A carefully-audited, tiny amount of
unsafe(fully documented).
This crate is released under the MIT license.
Attribution: Portions of this crate were generated by an AI assistant (ChatGPT) based on an idea by alisio85.
Goals
- Kernel-friendly: deterministic, allocation-free,
no_stdby default. - Safety: safe API prevents invalid access; generation counters detect stale keys.
- Small surface area: easy to audit, easy to port, easy to embed.
Non-goals
- Variable-capacity growth (no heap).
- Locking / synchronization (bring your own spinlock/mutex if you need concurrency).
- Architecture-specific features (this crate is platform-agnostic).
Quick example
use Slab;
let mut tasks: = new;
let a = tasks.insert.unwrap;
let b = tasks.insert.unwrap;
assert_eq!;
assert_eq!;
// `b` is now stale: generation check prevents accidental re-use.
assert!;
Documentation
- API docs on docs.rs
- Project documentation in
docs/:docs/MANUAL.md(ultra-detailed)docs/COOKBOOK.mddocs/SAFETY.mddocs/DESIGN.mddocs/FAQ.mddocs/CI_AND_RELEASE.mddocs/SEMVER.mddocs/HANDLES_AND_GENERATIONS.md
Minimum supported Rust
This crate targets Rust 2024 edition and is intended to be used with a recent stable toolchain.