Skip to main content

HostVtable

Struct HostVtable 

Source
#[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: u32

size_of::<HostVtable>() on the host side. A plugin built against a later ABI reads only the fields this covers.

§_pad: u32

Zero. Keeps ctx 8-aligned on every target.

§ctx: *mut c_void

Opaque 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.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more