pub struct TypeEntry {
pub type_id: TypeId,
pub type_name: &'static str,
pub push_arg_fn: PushArgFn,
pub add_cell_fn: AddCellFn,
pub add_source_fn: AddSourceFn,
pub call_dyn_fn: CallDynFn,
pub eq_dyn_fn: fn(&dyn Any, &dyn Any) -> bool,
pub default_fn: Option<fn() -> Box<dyn Any>>,
pub add_conditional_fn: AddConditionalFn,
pub value_type_fn: fn() -> ValueType,
/* private fields */
}Expand description
Metadata for a single type registered in a TypeRegistry.
Cell/source/conditional adapters require boxed values of type_id; callers establish
this before dispatch. Checked host calls report runtime mismatches. Erased equality
returns false if either operand has another concrete type.
§Examples
let registry = adam_lang::TypeRegistry::new();
let entry = registry.get("i32").unwrap();
let mut sheet = adam_rs::Sheet::new();
let cell = (entry.add_cell_fn)(&mut sheet, Box::new(7i32));
assert_eq!(*sheet.read::<i32>(cell).unwrap(), 7);
assert!((entry.eq_dyn_fn)(&7i32, &7i32));
assert!(!(entry.eq_dyn_fn)(&"other", &"other"));
let source = (entry.add_source_fn)(&mut sheet, Box::new(8i32));
assert_eq!(*sheet.read::<i32>(source).unwrap(), 8);
let mut segment = cel_runtime::DynSegment::new::<()>();
(entry.push_arg_fn)(&mut segment, 0);
let result = (entry.call_dyn_fn)(&mut segment, &[&9i32]).unwrap();
assert_eq!(*result.downcast::<i32>().unwrap(), 9);Fields§
§type_id: TypeIdRuntime type identity.
type_name: &'static strRust type name for error messages.
push_arg_fn: PushArgFnRegisters a push_arg<T> op at the given argument index.
add_cell_fn: AddCellFnCreates a sheet cell from a Box<dyn Any> holding a T.
add_source_fn: AddSourceFnCreates a source-kind sheet cell (via [Sheet::add_source]) from a Box<dyn Any> holding
a T.
call_dyn_fn: CallDynFnCalls DynSegment::call_dyn::<T> and boxes the result.
eq_dyn_fn: fn(&dyn Any, &dyn Any) -> boolCompares registered values; returns false if either operand has another concrete type.
default_fn: Option<fn() -> Box<dyn Any>>Constructs a default T if the type implements Default; otherwise None.
add_conditional_fn: AddConditionalFnCalls Sheet::add_conditional::<T> with type-erased branch keys.
value_type_fn: fn() -> ValueTypeBuilds complete concrete leaf metadata with the registered capabilities.