#[repr(C)]pub struct HostV1 {
pub abi: u32,
pub size: u32,
pub context: *mut c_void,
pub emit: unsafe extern "C" fn(context: *mut c_void, records: *const u8, len: usize) -> i32,
pub resource: unsafe extern "C" fn(context: *mut c_void, name: *const u8, name_len: usize, len: *mut usize) -> *const u8,
pub fail: unsafe extern "C" fn(context: *mut c_void, message: *const u8, len: usize),
pub log: unsafe extern "C" fn(context: *mut c_void, level: u32, message: *const u8, len: usize),
pub resource_path: unsafe extern "C" fn(context: *mut c_void, name: *const u8, name_len: usize, len: *mut usize) -> *const u8,
}Expand description
What a host gives a native plugin instance. Every function takes context first.
Pointers passed to these functions are borrowed for the call alone. /1 grows only by fields
appended here; a plugin reads abi and size first, refuses a table shorter than
HOST_V1_BASE_BYTES and uses only the fields size covers.
Fields§
§abi: u32§size: u32Bytes of the table as the host that filled it knows it.
context: *mut c_voidThe host’s own state for this instance.
emit: unsafe extern "C" fn(context: *mut c_void, records: *const u8, len: usize) -> i32Takes a batch of records; returns status::OK, or status::FAILED once the
session has refused an emit and the plugin should stop.
resource: unsafe extern "C" fn(context: *mut c_void, name: *const u8, name_len: usize, len: *mut usize) -> *const u8The resource name (UTF-8) and its length, or null when the manifest declares none by that
name. The bytes stay valid until the instance is destroyed.
fail: unsafe extern "C" fn(context: *mut c_void, message: *const u8, len: usize)Records why the call about to return status::FAILED failed (UTF-8).
log: unsafe extern "C" fn(context: *mut c_void, level: u32, message: *const u8, len: usize)Writes a diagnostic (UTF-8) at a log_level.
resource_path: unsafe extern "C" fn(context: *mut c_void, name: *const u8, name_len: usize, len: *mut usize) -> *const u8The absolute path (UTF-8) of the supplied file, filled directory slot or directory under
one named name, and its length; null for a pinned resource, an empty or undeclared name,
or a path that is not UTF-8. Valid until the instance is destroyed. Appended within /1.