#consistent-hashing #distributed #ceph #crush #hashing

mycrush

Rust implementation of the CRUSH (Controlled Replication Under Scalable Hashing) algorithm

4 releases (2 stable)

Uses new Rust 2024

1.0.1 Oct 9, 2025
0.1.2 Oct 8, 2025
0.1.0 Oct 8, 2025

#2162 in Algorithms

Download history 21/week @ 2025-11-25 171/week @ 2025-12-02 1/week @ 2026-01-20 99/week @ 2026-01-27 131/week @ 2026-02-03 341/week @ 2026-02-10

572 downloads per month

GPL-3.0-or-later OR LGPL-2.1-or-later

195KB
5K SLoC

🥰 mycrush

mycrush is a pure Rust implementation of the CRUSH algorithm, converted from C with c2rust and then refactored for safety and WASM compatibility.

Features

  • Pure Rust API - No C ABI compatibility layer
  • WASM Compatible - Builds for wasm32-unknown-unknown target
  • Safe Rust patterns - Uses Result types and safe abstractions where possible
  • No symbol conflicts - Independent from the C libcrush library
  • Modern error handling - CrushError enum instead of integer error codes

Building

# Regular build
cargo build --package mycrush

# WASM build
cargo build --package mycrush --target wasm32-unknown-unknown --release

# Run tests
cargo test --package mycrush

Status

The library has been successfully converted to a pure Rust implementation:

  • All #[unsafe(no_mangle)] and extern "C" declarations removed
  • Safe Rust implementations for helper functions
  • WASM compatibility verified
  • All tests passing

For detailed conversion notes, see PURE_RUST_CONVERSION.md.

Note

This library still uses some internal libc functions (malloc/free/memcpy/memset) but is WASM-compatible through the libc crate's WASM support. Future work will replace these with pure Rust alternatives.

Dependencies

~2.3–6.5MB
~124K SLoC