Skip to main content

matchy_paraglob/
lib.rs

1//! Unified Pattern Matcher - Combines Aho-Corasick and Glob Matching
2//!
3//! Paraglob provides multi-pattern matching combining literal strings and glob patterns
4//! in a single optimized data structure.
5
6// Internal modules
7pub(crate) mod glob;
8pub(crate) mod literal_hash;
9mod paraglob_offset;
10
11// Temporary modules until Phase 8 (will be extracted to matchy-format)
12pub mod error; // Public so matchy-format can use ParaglobError
13pub mod offset_format; // Public for validation and external format access
14pub mod simd_utils;
15
16// Re-export main types
17pub use paraglob_offset::{Paraglob, ParaglobBuilder};
18
19// Re-export MatchMode from shared crate
20pub use matchy_match_mode::MatchMode;
21
22// Re-export GlobError for external error handling
23pub use glob::GlobError;
24
25/// Validate a glob pattern without building a matcher.
26///
27/// This is useful for validating user input before adding it to a database.
28///
29/// # Examples
30///
31/// ```
32/// use matchy_paraglob::validate_glob_pattern;
33///
34/// // Valid patterns
35/// assert!(validate_glob_pattern("*.txt").is_ok());
36/// assert!(validate_glob_pattern("file[0-9].txt").is_ok());
37///
38/// // Invalid patterns
39/// assert!(validate_glob_pattern("[unclosed").is_err());
40/// assert!(validate_glob_pattern("file\\").is_err());  // Trailing backslash
41/// ```
42pub fn validate_glob_pattern(pattern: &str) -> Result<(), GlobError> {
43    // Use CaseSensitive for validation - mode doesn't matter for syntax checking
44    glob::GlobPattern::new(pattern, MatchMode::CaseSensitive)?;
45    Ok(())
46}
47
48// Validation module for paraglob structures
49pub mod validation;
50
51// Re-export validation types for convenience
52pub use validation::{
53    build_pattern_info, get_pattern_data_offsets, validate_ac_literal_mapping,
54    validate_meta_word_mappings, validate_patterns, ParaglobStats, ParaglobValidationResult,
55};