+use std::any::Any;
+
use serde_json::Value;
use serde_derive::Serialize;
use tera::Tera;
-pub type ToCall = fn(row: &serde_json::Value) -> String;
+pub type ToCall = fn(row: &serde_json::Value, user_data: &Option<Box<dyn Any>>) -> String;
#[derive(Copy, Clone, Serialize)]
pub enum Align {
align: Align,
hidden: bool,
to_call: Option<ToCall>,
+ user_data: Option<Box<dyn Any>>,
}
impl Column {
align: Align::Left,
hidden: false,
to_call: None,
+ user_data: None,
}
}
self.hidden
}
- pub fn set_to_call(&mut self, to_call: Option<ToCall>) {
+ pub fn set_to_call(&mut self, to_call: Option<ToCall>, user_data: Option<Box<dyn Any>>) {
self.to_call = to_call;
+ self.user_data = user_data;
}
}
match c.to_call {
None => context.insert("value", ""),
Some(call) => {
- let v = (call)(&row);
+ let v = (call)(&row, &c.user_data);
context.insert("value", v.as_str());
}
}