#[repr(C)]pub struct MainFunctionAbi {
pub data: usize,
pub virtual_table: usize,
}Expand description
Plain-data payload of GET_MAIN_FUNCTION: the two words of a
MainFunction fat pointer, so the payload size and layout are
unchanged. A function pointer is not plain data, so the payload type
is this mirror; the host converts it back where the value is read.
The value carries the owning Box<dyn Fn> pointer, so it is not
Clone/Copy: convert it with MainFunctionAbi::into_main_function
at most once, or the box would be freed twice.
Fields§
§data: usize§virtual_table: usizeImplementations§
Source§impl MainFunctionAbi
impl MainFunctionAbi
Sourcepub unsafe fn into_main_function(self) -> MainFunction
pub unsafe fn into_main_function(self) -> MainFunction
Reinterprets a payload written by the host device as the function pointer it carries.
The payload holds an owning Box<dyn Fn>, so it must be converted at
most once: converting a copy twice would free the box twice.
§Safety
The value must come from a MainFunction produced by the host:
arbitrary bytes are not a valid function pointer.