# 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_std` by 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

```rust
use os_slab_vault::Slab;

let mut tasks: Slab<&'static str, 4> = Slab::new();

let a = tasks.insert("init").unwrap();
let b = tasks.insert("idle").unwrap();

assert_eq!(tasks.get(a), Some(&"init"));
assert_eq!(tasks.remove(b).unwrap(), "idle");

// `b` is now stale: generation check prevents accidental re-use.
assert!(tasks.get(b).is_none());
```

## Documentation

- API docs on [docs.rs](https://docs.rs/os_slab_vault)
- Project documentation in `docs/`:
  - `docs/MANUAL.md` (ultra-detailed)
  - `docs/COOKBOOK.md`
  - `docs/SAFETY.md`
  - `docs/DESIGN.md`
  - `docs/FAQ.md`
  - `docs/CI_AND_RELEASE.md`
  - `docs/SEMVER.md`
  - `docs/HANDLES_AND_GENERATIONS.md`

## Minimum supported Rust

This crate targets **Rust 2024 edition** and is intended to be used with a recent stable toolchain.

