Skip to main content

ModuleVTable

Struct ModuleVTable 

Source
#[repr(C)]
pub struct ModuleVTable { pub init: Option<unsafe extern "C" fn(config: *const u8, config_len: usize) -> *mut c_void>, pub get_module_schema: Option<unsafe extern "C" fn(instance: *mut c_void, out_ptr: *mut *mut u8, out_len: *mut usize) -> i32>, pub get_module_artifacts: Option<unsafe extern "C" fn(instance: *mut c_void, out_ptr: *mut *mut u8, out_len: *mut usize) -> i32>, pub invoke: Option<unsafe extern "C" fn(instance: *mut c_void, function: *const u8, function_len: usize, args: *const u8, args_len: usize, out_ptr: *mut *mut u8, out_len: *mut usize) -> i32>, pub invoke_ex: Option<unsafe extern "C" fn(instance: *mut c_void, function: *const u8, function_len: usize, args: *const u8, args_len: usize, out: *mut ModuleInvokeResult) -> i32>, pub free_buffer: Option<unsafe extern "C" fn(ptr: *mut u8, len: usize)>, pub drop: Option<unsafe extern "C" fn(instance: *mut c_void)>, }
Expand description

Function pointer types for the base module capability (shape.module).

Fields§

§init: Option<unsafe extern "C" fn(config: *const u8, config_len: usize) -> *mut c_void>

Initialize module instance with MessagePack-encoded config.

§get_module_schema: Option<unsafe extern "C" fn(instance: *mut c_void, out_ptr: *mut *mut u8, out_len: *mut usize) -> i32>

Return MessagePack-encoded ModuleSchema.

The caller must free the output buffer with free_buffer.

§get_module_artifacts: Option<unsafe extern "C" fn(instance: *mut c_void, out_ptr: *mut *mut u8, out_len: *mut usize) -> i32>

Return MessagePack-encoded module artifacts payload.

This is an opaque host-defined payload for bundled Shape modules (source and/or precompiled artifacts). ABI keeps this generic.

The caller must free the output buffer with free_buffer.

§invoke: Option<unsafe extern "C" fn(instance: *mut c_void, function: *const u8, function_len: usize, args: *const u8, args_len: usize, out_ptr: *mut *mut u8, out_len: *mut usize) -> i32>

Invoke a module function with MessagePack-encoded shape_wire::WireValue array.

function is a UTF-8 function name (bytes). args is a MessagePack-encoded Vec<shape_wire::WireValue> payload. On success, out_ptr/out_len contain MessagePack-encoded shape_wire::WireValue.

§invoke_ex: Option<unsafe extern "C" fn(instance: *mut c_void, function: *const u8, function_len: usize, args: *const u8, args_len: usize, out: *mut ModuleInvokeResult) -> i32>

Invoke a module function and return a typed payload (WireValue or table IPC).

function is a UTF-8 function name (bytes). args is a MessagePack-encoded Vec<shape_wire::WireValue> payload. On success, out must be filled with a valid payload descriptor.

§free_buffer: Option<unsafe extern "C" fn(ptr: *mut u8, len: usize)>

Free a buffer allocated by get_module_schema, invoke, or invoke_ex.

§drop: Option<unsafe extern "C" fn(instance: *mut c_void)>

Cleanup and destroy the instance.

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.

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.

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.