Skip to main content

universal_query

Function universal_query 

Source
pub unsafe extern "C" fn universal_query(
    ptr: *mut mx_erased,
    trait_tag: mx_tag,
) -> *const c_void
Expand description

Universal query function for trait dispatch.

Scans MX_TRAIT_DISPATCH for a matching (concrete_tag, trait_tag) pair. Returns the vtable pointer, or null if the trait is not implemented.

This replaces per-type query functions — a single function handles all types by reading from the global dispatch table.

§Safety

  • ptr must point to a valid mx_erased with a valid base vtable.
  • Must be called on R’s main thread.