ida-rs

Crates.ioida-rs
lib.rsida-rs
version0.1.1
created_at2025-10-20 07:21:47.149825+00
updated_at2025-10-20 09:08:58.161416+00
descriptionA thread-safe, no_std, sparse ID allocator using a radix tree. Ideal for systems programming.
homepage
repositoryhttps://github.com/TomGoh/ida-rs
max_upload_size
id1891544
size36,566
Haoze Wu (TomGoh)

documentation

README

ida-rs: An ID Allocator for Sparse ID Spaces

ida-rs provides a thread-safe, no_std compatible ID allocator suitable for systems-level programming, such as in OS kernels or embedded environments.

It is implemented as a radix tree, which makes it highly memory-efficient when dealing with sparse ID allocations (e.g., allocating ID 5 and ID 5,000,000 without allocating the space in between).

Features

  • no_std compatible: Usable in bare-metal environments.
  • Thread-Safe: All public methods are thread-safe, using a spinlock for synchronization.
  • Memory-Efficient for Sparse Sets: Ideal when allocated IDs are far apart.

Example

use ida_rs::Ida;

let ida = Ida::new();

// Allocate new IDs
let id1 = ida.alloc().unwrap();
let id2 = ida.alloc().unwrap();

assert_eq!(id1, 0);
assert_eq!(id2, 1);

// Free an ID
ida.free(id1);

// The next allocation reuses the freed ID
let id3 = ida.alloc().unwrap();
assert_eq!(id3, 0);

License

This project is licensed under either of

at your option.

Commit count: 0

cargo fmt