pub type SharedConverterGraph = Arc<RwLock<ConverterGraph>>;Expand description
Thread-safe wrapper type for concurrent registration/resolution.
use daedalus_data::convert::{ConverterBuilder, ConverterGraph, SharedConverterGraph};
use daedalus_data::model::{TypeExpr, Value, ValueType};
use std::sync::{Arc, RwLock};
let graph: SharedConverterGraph = Arc::new(RwLock::new(ConverterGraph::new()));
{
let mut g = graph.write().unwrap();
g.register(
ConverterBuilder::new(
"id",
TypeExpr::Scalar(ValueType::Bool),
TypeExpr::Scalar(ValueType::Bool),
|v| Ok(v),
)
.build_boxed(),
);
}
{
let g = graph.read().unwrap();
let res = g.resolve(&TypeExpr::Scalar(ValueType::Bool), &TypeExpr::Scalar(ValueType::Bool)).unwrap();
assert_eq!(res.provenance.total_cost, 0);
}Aliased Typeยง
pub struct SharedConverterGraph { /* private fields */ }