1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
//! # PSMatcher
//!
//! A pub/sub matcher algorithm implementation that efficiently matches events against subscriptions.
//! The algorithm pre-processes subscriptions into a matching tree for optimized event matching.
//!
//! ## Overview
//!
//! This crate provides a pub/sub matching system where:
//! - Subscriptions are conjunctions of elementary predicates
//! - Events must have at least one string attribute called "topic"
//! - The matching tree is built during pre-processing for efficient matching
//!
//! ## Example
//!
//! ```rust
//! use psmatcher::{Matcher, Subscription, ElementaryPredicate, ElementaryTest};
//! use psmatcher::event_types::{DefaultEvent, AttributeValue};
//!
//! // Create a matcher
//! let mut matcher = Matcher::new();
//!
//! // Create a subscription for weather updates in San Francisco
//! let subscription = Subscription::new("weather-sf")
//! .with_predicate(ElementaryPredicate::new(
//! ElementaryTest::Equals {
//! attribute: "topic".to_string(),
//! value: AttributeValue::String("weather".to_string()),
//! },
//! false,
//! ))
//! .with_predicate(ElementaryPredicate::new(
//! ElementaryTest::Equals {
//! attribute: "city".to_string(),
//! value: AttributeValue::String("San Francisco".to_string()),
//! },
//! false,
//! ));
//!
//! // Add the subscription to the matcher
//! matcher.add_subscription(subscription);
//!
//! // Create a subscription using regex pattern matching
//! let regex_subscription = Subscription::new("california-cities")
//! .with_predicate(ElementaryPredicate::new(
//! ElementaryTest::regex("topic".to_string(), "weather|forecast").unwrap(),
//! false,
//! ))
//! .with_predicate(ElementaryPredicate::new(
//! ElementaryTest::regex("city".to_string(), "San (Francisco|Jose|Diego)").unwrap(),
//! false,
//! ));
//!
//! // Add the regex subscription to the matcher
//! matcher.add_subscription(regex_subscription);
//!
//! // Create an event
//! let event = DefaultEvent::new("weather")
//! .with_attribute("city", AttributeValue::String("San Francisco".to_string()))
//! .with_attribute("temperature", AttributeValue::Float(72.5));
//!
//! // Match the event against subscriptions
//! let matches = matcher.match_event(&event).unwrap();
//!
//! // Check if our subscriptions matched
//! assert!(matches.contains("weather-sf"));
//! assert!(matches.contains("california-cities"));
//! ```
//!
//! For more examples and detailed documentation, see the [README](readme) module.
pub use MatcherError;
pub use TOPIC_STR;
pub use Matcher;
pub use ;
pub use Subscription;
pub use MatchingTree;
// Re-export event types for convenience
// Re-export traits for convenience
// In test context export helpers
// Re-export the readme module for documentation purposes
pub use _readme_doc;