Skip to main content

Module patterns

Module patterns 

Source
Expand description

Vectorscan-based pattern matching for complex validation.

This module provides high-performance regex matching using Vectorscan (the open-source fork of Intel Hyperscan). Key features:

  • Match thousands of patterns simultaneously
  • SIMD-accelerated on x86_64 (AVX2/AVX-512) and ARM (NEON)
  • Stream-oriented for network-speed processing
  • Zero-copy pattern matching

§Setup

Vectorscan requires the system library to be installed:

# macOS
brew install vectorscan

# Ubuntu/Debian
apt-get install libvectorscan-dev

# From source
git clone https://github.com/VectorCamp/vectorscan
cd vectorscan && cmake -B build && cmake --build build

§Usage

use wellformed_validate::patterns::{PatternDb, PatternId};

// Create a pattern database with built-in patterns
let db = PatternDb::with_builtins().unwrap();

// Match against input
let matches = db.scan("test@example.com");
assert!(matches.contains(PatternId::Email));

Structs§

MatchResult
Result of pattern matching.
PatternDb
Pattern database using regex crate (fallback).
PatternDef
Pre-compiled pattern definitions.

Enums§

PatternId
Pattern identifier for matching results.

Statics§

BUILTIN_PATTERNS
All built-in patterns.

Functions§

is_ein_format
Check if a string matches the EIN format.
is_email_format
Check if a string looks like an email address.
is_ssn_format
Check if a string matches the SSN format.
is_zip_format
Check if a string matches the US ZIP code format.