reactive_graph_std_value/behaviour/component/value_debugger/
functions.rs1use std::sync::Arc;
2use std::sync::LazyLock;
3
4use log::debug;
5use log::trace;
6use reactive_graph_behaviour_model_impl::entity::EntityBehaviourFactoryCreator;
7use reactive_graph_behaviour_model_impl::entity::EntityBehaviourFunctions;
8use reactive_graph_behaviour_model_impl::entity::EntityBehaviourFunctionsStorage;
9use serde_json::Value;
10
11use reactive_graph_std_value_model::NAMESPACE_VALUE;
12
13use crate::behaviour::component::value_debugger::ValueDebuggerFactory;
14
15pub type ValueDebuggerFunction = fn(Value);
16
17const FN_LOG_DEBUG: ValueDebuggerFunction = |v| {
18 debug!("{}", v);
19};
20
21const FN_LOG_TRACE: ValueDebuggerFunction = |v| {
22 trace!("{}", v);
23};
24
25const FACTORY_CREATOR: EntityBehaviourFactoryCreator<ValueDebuggerFunction> = |ty, f| Arc::new(ValueDebuggerFactory::new(ty.clone(), f));
27
28pub static VALUE_DEBUGGER_BEHAVIOURS: EntityBehaviourFunctionsStorage<ValueDebuggerFunction> = LazyLock::new(|| {
31 EntityBehaviourFunctions::<ValueDebuggerFunction>::with_namespace(NAMESPACE_VALUE, FACTORY_CREATOR)
32 .behaviour("value_debugger_debug", FN_LOG_DEBUG)
33 .behaviour("value_debugger_trace", FN_LOG_TRACE)
34 .get()
35});
36
37