rusty_expressions 0.2.1

Oniguruma remade in pure Rust: named groups, look-around, backreferences, subexp calls, absent expressions, callouts, per-regex encodings (UTF-8/16/32, Shift_JIS, Big5, EUC-*, GB18030, ISO-8859-*) and Perl/Python/Java/POSIX/GNU/Emacs/grep syntax dialects. Match-equivalent to Oniguruma 6.9.10 and ~3x faster than libonig. no_std + alloc with default-features = false, runs on wasm32, no C toolchain.
Documentation
//! Callout seam: function pointers so compiled [`Regex`](super::Regex) stays `Send + Sync`.

extern crate alloc;

use alloc::string::String;

/// Result of a callout.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CalloutResult {
    /// Continue matching (Oniguruma `ONIG_CALLOUT_SUCCESS` / 0).
    Success,
    /// Fail this alternative.
    Fail,
    /// `(*SKIP)`: continue matching, but if this whole attempt fails, resume
    /// the search at this position rather than at the next one.
    Skip,
}

/// Direction a contents-callout fires.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CalloutDir {
    Progress,
    Retraction,
    Both,
}

/// Context passed to a callout.
#[derive(Clone, Debug)]
pub struct CalloutCtx<'a> {
    pub name: &'a str,
    pub args: &'a str,
    pub tag: Option<&'a str>,
    pub body: &'a str,
    pub haystack: &'a [u8],
    pub current: usize,
    pub dir: CalloutDir,
}

/// `fn` pointer: `Send + Sync`, no capture. Closures belong in a match-time wrapper.
pub type CalloutFn = fn(&CalloutCtx<'_>) -> CalloutResult;

/// A ready-made hook that always asks the engine to skip.
///
/// Install as a `MatchParam` callout when you want every callout site to
/// behave as `(*SKIP)` without writing the closure yourself. The engine treats
/// `(*COUNT)` as Success and records nothing unless a named hook is installed;
/// `(*SKIP)` itself is implemented in exec, not here.
pub fn builtin_skip(_ctx: &CalloutCtx<'_>) -> CalloutResult {
    CalloutResult::Skip
}

/// Format a contents-callout body for debugging (no C callback).
pub fn describe(ctx: &CalloutCtx<'_>) -> String {
    alloc::format!(
        "callout name={} args={} pos={}",
        ctx.name,
        ctx.args,
        ctx.current
    )
}