pub unsafe fn mx_query(sexp: SEXP, tag: mx_tag) -> *const c_voidExpand description
Query an object for an interface vtable by tag.
Looks up whether the object implements the trait identified by tag,
and returns a pointer to the vtable if so.
§Arguments
sexp- R external pointer wrapping an erased objecttag- Tag identifying the requested trait interface
§Returns
- Non-null pointer to the trait’s vtable if implemented
- Null pointer if:
sexpis not a valid erased object- The object does not implement the requested trait
§Safety
sexpmust be a valid SEXP- Must be called on R’s main thread
- The returned pointer must be cast to the correct vtable type
§Example
ⓘ
let vtable = unsafe { mx_query(obj, TAG_FOO) };
if !vtable.is_null() {
let foo_vtable = vtable.cast::<FooVTable>();
// Call method through vtable...
}