Skip to main content

divsufsort_rs/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3extern crate alloc;
4
5mod constants;
6mod divsufsort;
7#[cfg(feature = "c-bench")]
8pub mod ffi;
9mod sssort;
10mod trsort;
11mod utils;
12
13pub use divsufsort::{divbwt, divsufsort};
14pub use utils::{
15    SufCheckError, bw_transform, inverse_bw_transform, sa_search, sa_simplesearch, sufcheck,
16};
17
18/// Errors returned by the public API of this crate.
19#[derive(Debug, PartialEq, Eq)]
20pub enum DivSufSortError {
21    /// A supplied argument is invalid (e.g. slice length mismatch or out-of-range index).
22    InvalidArgument,
23    /// An internal allocation failed. Currently unused; reserved for future use.
24    AllocationFailure,
25}
26
27impl core::fmt::Display for DivSufSortError {
28    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
29        match self {
30            Self::InvalidArgument => write!(f, "invalid argument"),
31            Self::AllocationFailure => write!(f, "allocation failure"),
32        }
33    }
34}
35
36#[cfg(feature = "std")]
37impl std::error::Error for DivSufSortError {}