pub trait TypeMapper {
type L: Clone + Debug;
type V: Clone + Debug;
// Required methods
fn label(&self, s: &str) -> Result<Self::L, String>;
fn string_value(&self, s: &str) -> Result<Self::V, String>;
fn num_value(&self, n: f64) -> Result<Self::V, String>;
fn bool_value(&self, b: bool) -> Result<Self::V, String>;
fn node_ref(&self, name: &str) -> Result<Self::V, String>;
}Expand description
Maps DSL literal types to concrete pattern types.
The DSL parses labels as strings and values as strings/numbers/bools/node-refs. This trait bridges from those parsed representations to the target type system.
All methods return Result to support fallible mappings (e.g., looking up
a string label in a predicate registry that may not contain the label).
§Example
ⓘ
struct WkMapper { labels: HashMap<String, u32> }
impl TypeMapper for WkMapper {
type L = u32;
type V = paracausality::Value;
fn label(&self, s: &str) -> Result<u32, String> {
self.labels.get(s).copied()
.ok_or_else(|| format!("unknown predicate '{}'", s))
}
// ...
}Required Associated Types§
Required Methods§
Sourcefn label(&self, s: &str) -> Result<Self::L, String>
fn label(&self, s: &str) -> Result<Self::L, String>
Convert a label string to the target label type.