camel_api/filter.rs
1use crate::exchange::Exchange;
2use std::sync::Arc;
3
4/// Predicate that determines whether an exchange passes the filter.
5/// Returns `true` to forward the exchange into the filter body; `false` to skip it.
6pub type FilterPredicate = Arc<dyn Fn(&Exchange) -> bool + Send + Sync>;
7
8#[cfg(test)]
9mod tests {
10 use super::*;
11 use crate::{Exchange, Message};
12
13 #[test]
14 fn test_filter_predicate_is_callable() {
15 let pred: FilterPredicate = Arc::new(|ex: &Exchange| ex.input.body.as_text().is_some());
16 let ex = Exchange::new(Message::new("hello"));
17 assert!(pred(&ex));
18 }
19}