# libsais-rs
`libsais-rs` is a Rust translation of [`IlyaGrebnov/libsais`](https://github.com/IlyaGrebnov/libsais) for suffix array construction and related transforms.
This crate currently tracks upstream `libsais` version `2.10.4`. The Rust code is intended to stay behaviorally close to upstream, but this remains an early translation and should be treated as experimental until it has seen broader validation.
## Status
- Intended for users who want a Rust-native library interface to `libsais`
- Translation project, not an official upstream release
- Bug reports should go to this repository, not the original `libsais` project
## Usage
```toml
[dependencies]
libsais-rs = "0.1.0"
```
```rust
use libsais_rs::{libsais, SaSint};
fn main() {
let text = b"banana";
let mut sa = vec![0 as SaSint; text.len()];
let rc = libsais(text, &mut sa, 0, None);
assert_eq!(rc, 0, "libsais failed with status {rc}");
println!("{sa:?}");
}
```
Notes:
- `sa.len()` must be at least `text.len() + fs`
- `fs` is extra scratch space made available at the tail of `sa`
- `freq`, when used, must have length at least `256`
## Development
Run tests with:
```bash
cargo test
```
Run the local Rust-vs-C benchmark example with:
```bash
cargo run --release --example bench_vs_c
```
## Upstream Sources
The repository vendors the upstream C sources under [`libsais/`](libsais/) for reference and parity testing.
Upstream project:
- <https://github.com/IlyaGrebnov/libsais>
## License
Apache License 2.0.