Skip to main content

TypeEntry

Struct TypeEntry 

Source
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: TypeId

Runtime type identity.

§type_name: &'static str

Rust type name for error messages.

§push_arg_fn: PushArgFn

Registers a push_arg<T> op at the given argument index.

§add_cell_fn: AddCellFn

Creates a sheet cell from a Box<dyn Any> holding a T.

§add_source_fn: AddSourceFn

Creates a source-kind sheet cell (via [Sheet::add_source]) from a Box<dyn Any> holding a T.

§call_dyn_fn: CallDynFn

Calls DynSegment::call_dyn::<T> and boxes the result.

§eq_dyn_fn: fn(&dyn Any, &dyn Any) -> bool

Compares 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: AddConditionalFn

Calls Sheet::add_conditional::<T> with type-erased branch keys.

§value_type_fn: fn() -> ValueType

Builds complete concrete leaf metadata with the registered capabilities.

Trait Implementations§

Source§

impl Clone for TypeEntry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.