#[repr(C)]pub struct HostVtable {
pub struct_size: u32,
pub _pad: u32,
pub ctx: *mut c_void,
pub emit_event: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize) -> i32>,
pub log: Option<unsafe extern "C" fn(_: *mut c_void, level: i32, _: *const u8, _: usize)>,
pub wake: Option<unsafe extern "C" fn(*mut c_void)>,
}Expand description
What the host offers a plugin: an opaque context pointer and the calls a plugin makes back into the engine.
The table and everything it points at live for the process. ctx is
host-owned and opaque; a plugin passes it back verbatim and never frees
it.
Every entry is callable from any thread, at any time, including concurrently with a call the plugin is already inside. None of them block on the tick thread, and the host never calls back into the plugin from inside one, so a plugin’s worker thread can emit while the tick thread is running one of its functions.
Fields§
§struct_size: u32size_of::<HostVtable>() on the host side. A plugin built against a
later ABI reads only the fields this covers.
_pad: u32Zero. Keeps ctx 8-aligned on every target.
ctx: *mut c_voidOpaque host state, passed back to every entry below.
emit_event: Option<unsafe extern "C" fn(*mut c_void, *const u8, usize) -> i32>Deliver a bincode PluginEvent to the engine.
Returns OK when the event was queued, ERR when the queue is
gone (the app is shutting down) or the payload did not decode.
log: Option<unsafe extern "C" fn(_: *mut c_void, level: i32, _: *const u8, _: usize)>Write a UTF-8 line to the engine’s diagnostic output at level, one
of the LogLevel codes.
wake: Option<unsafe extern "C" fn(*mut c_void)>Ask the engine for another tick, so an event emitted from a worker thread is drained without waiting for input.