# cube-rust
[](https://crates.io/crates/cube-rust)
[](https://docs.rs/cube-rust)
[](https://github.com/coshz/cube/tree/HEAD/bindings/rust#license)
[](https://github.com/coshz/cube/tree/HEAD/bindings/rust)
A high-performance, memory-safe Rust FFI wrapper for a C++ Rubik's Cube solver engine (Two-Phase Algorithm).
## 🚀 Features
- **Idiomatic API Design**: Supports both functional chaining for immutable transformations and efficient in-place mutation.
- **Rich Error Diagnostics**: `CubeError` fully implements `std::error::Error` and `Display`, accurately exposing underlying C++ engine diagnostic messages.
- **Batteries Included**: Zero manual C++ configuration required. Automatically compiles C++17 source code and handles static linking via `cc` build script.
## 📦 Installation
Add `cube-rust` to your project using `cargo`:
```bash
cargo add cube-rust
```
Or add it manually to `Cargo.toml`:
```toml
[dependencies]
cube-rust = "0.5.0"
```
## 💡 Quick Start
```rust
use cube_rust::{Cube, cube_init};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize library (load or build tables)
cube_init(false,"tables/");
// 1. Initialize a cube in standard solved state
let mut cube = Cube::default();
// 2. Apply moves
cube.apply_maneuver_mut("R U F' D2").unwrap();
// 3. Check if the scrambled state is solvable
assert!(cube.is_solvable());
// 4. Solve the cube safely
match cube.solve() {
Ok(solution) => println!("Solution: {solution}"),
Err(err) => eprintln!("Failed to solve: {err}"),
}
Ok(())
}
```