condition_matcher/
lib.rs

1//! # Condition Matcher
2//!
3//! A flexible and type-safe condition matching library for Rust with automatic struct field access.
4//!
5//! ## Features
6//!
7//! - **Automatic struct matching** with derive macro
8//! - Multiple matching modes (AND, OR, XOR)
9//! - Support for various condition types (value, length, type, field)
10//! - String operations (contains, starts_with, ends_with)
11//! - Numeric comparisons on fields
12//! - Detailed match results with error information
13//! - Builder pattern for ergonomic API
14//! - Optional serde and regex support
15//!
16//! ## Quick Start
17//!
18//! ```rust
19//! use condition_matcher::{Matcher, MatcherMode, Condition, ConditionSelector, ConditionOperator, Matchable, MatchableDerive};
20//!
21//! #[derive(MatchableDerive, PartialEq, Debug)]
22//! struct User {
23//!     name: String,
24//!     age: u32,
25//! }
26//!
27//! let user = User { name: "Alice".to_string(), age: 30 };
28//!
29//! let mut matcher = Matcher::new(MatcherMode::AND);
30//! matcher.add_condition(Condition {
31//!     selector: ConditionSelector::FieldValue("age", &18u32),
32//!     operator: ConditionOperator::GreaterThanOrEqual,
33//! });
34//!
35//! assert!(matcher.run(&user).unwrap());
36//! ```
37//!
38//! ## Builder API
39//!
40//! ```rust
41//! use condition_matcher::{MatcherBuilder, MatcherMode};
42//!
43//! let matcher = MatcherBuilder::<&str>::new()
44//!     .mode(MatcherMode::AND)
45//!     .length_gte(4)
46//!     .value_not_equals("bad")
47//!     .build();
48//!
49//! assert!(matcher.run(&"good").unwrap());
50//! ```
51
52pub mod condition;
53pub mod matcher;
54
55// Re-export main types for convenience
56pub use condition::{Condition, ConditionOperator, ConditionSelector};
57pub use matcher::{
58    field, ConditionResult, FieldConditionBuilder, MatchError, MatchResult, Matchable,
59    MatchableDerive, Matcher, MatcherBuilder, MatcherMode,
60};