Skip to main content

Crate rusty_expressions

Crate rusty_expressions 

Source
Expand description

§rusty_expressions – Oniguruma, remade in pure Rust

An Oniguruma-class regular-expression engine: named groups, look-around, backreferences, subexp calls, atomic and possessive groups, absent expressions, conditionals, callouts, per-regex encodings and pluggable syntax dialects. No C, no FFI, no onig-sys, no_std + alloc, and it builds for wasm32-unknown-unknown.

It is match-equivalent to Oniguruma 6.9.10 on a harvested corpus and on tens of thousands of differential cases run against live libonig, and about 3x faster than libonig on search.

use rusty_expressions::{Encoding, Options, Regex, Syntax};

let re = Regex::new("ca+t", Options::NONE, Encoding::UTF8, Syntax::ONIGURUMA)?;
let m = re.search(b"one cat two")?.expect("match");
assert_eq!(m.range(), 4..7);

Offsets are byte offsets into the haystack, exactly as Oniguruma’s OnigRegion reports them.

Modules§

compatcompat
Optional Oniguruma-shaped C ABI (onig_new / regex_t).
count
Deterministic work counters for the expressions VM.

Structs§

CalloutCtx
Context passed to a callout.
CaptureTree
One node in the capture-history tree (OnigCaptureTreeNode).
Encoding
Built-in encodings plus a hook for user encodings (OnigEncodingType).
Error
Engine error. Pattern-position is set for compile failures.
MatchParam
Limits applied during match/search. 0 on a counter means unlimited.
Options
Compile- and search-time option bits (Oniguruma OnigOptionType).
RegSet
Set of compiled regexes. All must share an encoding. FIND_LONGEST is refused.
Regex
Compiled regular expression. Send + Sync.
Region
One match: whole-match range plus numbered (and optional named) groups.
ReqLit
A byte sequence every match must contain, with its distance from the match start, and optionally the class run that must immediately precede it.
Syntax
Syntax operator/behavior bits (OnigSyntaxType).
UserProperty
User-defined Unicode property: name -> inclusive ranges.

Enums§

CalloutDir
Direction a contents-callout fires.
CalloutResult
Result of a callout.
ErrorKind
Discriminated error kind (Oniguruma codes mapped to Rust).

Constants§

DEFAULT_MATCH_STACK_LIMIT
Finite match-stack default (Oniguruma ships 0/unlimited).
DEFAULT_RETRY_LIMIT_IN_MATCH
Oniguruma default: 10_000_000 retries in match. 0 = unlimited.
DEFAULT_RETRY_LIMIT_IN_SEARCH
Finite search-retry default (Oniguruma ships 0/unlimited; we bound wasm/mesh).

Functions§

find_all
Grep-like op: return byte ranges of matches of pattern in hay.
find_all_str
UTF-8 convenience for find_all.
format_matches
Format matches for a CLI/example surface.
is_match_str
True if pattern matches anywhere in hay.
rusty_alloc_enabled
Whether this build installed rusty_alloc as the global allocator.
scan
Scan hay for non-overlapping matches. Empty matches advance one character.
sql_syntax
SQL-like variable metas: % = .*, _ = .

Type Aliases§

CalloutFn
fn pointer: Send + Sync, no capture. Closures belong in a match-time wrapper.