Skip to main content

Crate ferroni

Crate ferroni 

Source
Expand description

§Ferroni

Pure-Rust regex engine based on Oniguruma, with SIMD-accelerated search via memchr.

Ferroni is a line-by-line port of Oniguruma’s C source into Rust – same structure, same function names, same semantics. No bindings, no FFI.

§Quick Start

use ferroni::prelude::*;

let re = Regex::new(r"\d{4}-\d{2}-\d{2}").unwrap();
let m = re.find("Date: 2026-02-12").unwrap();
assert_eq!(m.as_str(), "2026-02-12");
assert_eq!(m.start(), 6);

For fine-grained control, use [RegexBuilder]:

use ferroni::prelude::*;

let re = Regex::builder(r"hello")
    .case_insensitive(true)
    .build()
    .unwrap();
assert!(re.is_match("Hello World"));

§Low-Level C-Style API

The full C-ported API is also available for advanced usage:

use ferroni::regcomp::onig_new;
use ferroni::regexec::onig_search;
use ferroni::oniguruma::*;
use ferroni::regsyntax::OnigSyntaxOniguruma;

let reg = onig_new(
    b"\\d{4}-\\d{2}-\\d{2}",
    ONIG_OPTION_NONE,
    &ferroni::encodings::utf8::ONIG_ENCODING_UTF8,
    &OnigSyntaxOniguruma,
).unwrap();

let input = b"Date: 2026-02-12";
let (result, region) = onig_search(
    &reg, input, input.len(), 0, input.len(),
    Some(OnigRegion::new()), ONIG_OPTION_NONE,
);

assert!(result >= 0);
assert_eq!(result, 6); // match starts at byte 6

§Module Structure

Each C source file maps 1:1 to a Rust module:

C FileRust ModulePurpose
regparse.cregparsePattern parser
regcomp.cregcompAST-to-bytecode compiler
regexec.cregexecVM executor
regint.hregintInternal types and opcodes
oniguruma.honigurumaPublic types and constants
regenc.cregencEncoding trait
regsyntax.cregsyntax12 syntax definitions
regset.cregsetMulti-regex search (RegSet)
regerror.cregerrorError messages
regtrav.cregtravCapture tree traversal

Modules§

api
encodings
error
oniguruma
prelude
Prelude
regcomp
regenc
regerror
regexec
regint
regparse
regparse_types
regset
regsyntax
regtrav
scanner
unicode