[−][src]Function mmap_json_file::distinct_of_field
pub fn distinct_of_field<'a, T: 'static, F>(
f: String,
filter: F,
o: String
) -> Result<i32> where
T: DeserializeOwned + Debug + Clone + Send + Serialize,
F: Fn(T) -> String,
Disctinct values of the contents of a json field.
f
Filename and full accesislbe path of the input json filefilter
A closure that can handle an input parameter of type T and provide the field with distincts.o
Filename and full accesislbe path of the output json file.
Input types
T
The type of the structure.F
Closure template with input function type.
Return
count
No of distinct records found.
Example usage
use mmap_json_file; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone, Default)] struct TestSimple { a: Option<String>, c: Option<String>, } #[derive(Serialize, Deserialize, Debug, Clone, Default)] struct TestSimpleNested { b: Option<TestSimple>, c: Option<String>, } #[derive(Serialize, Deserialize, Debug, Clone, Default)] struct TestSimpleCompound { a: Option<TestSimpleNested>, f: Option<String>, } let filter = |record: TestSimple| -> String { record.a.unwrap() }; let _res = mmap_json_file::distinct_of_field::< TestSimple, Box<dyn Fn(TestSimple) -> String>, >("data/test_simple.json".to_string(), Box::new(filter), "output".to_string());