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
use std::collections::HashMap;
use crate::errors::Result;
use serde_json::value::Value;
pub mod array;
pub mod common;
pub mod number;
pub mod object;
pub mod string;
pub trait Filter: Sync + Send {
fn filter(&self, value: &Value, args: &HashMap<String, Value>) -> Result<Value>;
fn is_safe(&self) -> bool {
false
}
}
impl<F> Filter for F
where
F: Fn(&Value, &HashMap<String, Value>) -> Result<Value> + Sync + Send,
{
fn filter(&self, value: &Value, args: &HashMap<String, Value>) -> Result<Value> {
self(value, args)
}
}