Skip to main content

LanguageRuntimeVTable

Struct LanguageRuntimeVTable 

Source
#[repr(C)]
pub struct LanguageRuntimeVTable { pub init: Option<unsafe extern "C" fn(config: *const u8, config_len: usize) -> *mut c_void>, pub register_types: Option<unsafe extern "C" fn(instance: *mut c_void, types: *const u8, types_len: usize) -> i32>, pub compile: Option<unsafe extern "C" fn(instance: *mut c_void, name: *const u8, name_len: usize, source: *const u8, source_len: usize, param_names: *const u8, param_names_len: usize, param_types: *const u8, param_types_len: usize, return_type: *const u8, return_type_len: usize, is_async: bool, out_error: *mut *mut u8, out_error_len: *mut usize) -> *mut c_void>, pub invoke: Option<unsafe extern "C" fn(instance: *mut c_void, handle: *mut c_void, args: *const u8, args_len: usize, out_ptr: *mut *mut u8, out_len: *mut usize) -> i32>, pub dispose_function: Option<unsafe extern "C" fn(instance: *mut c_void, handle: *mut c_void)>, pub language_id: Option<unsafe extern "C" fn(instance: *mut c_void) -> *const c_char>, pub get_lsp_config: Option<unsafe extern "C" fn(instance: *mut c_void, out_ptr: *mut *mut u8, out_len: *mut usize) -> 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)>, pub error_model: ErrorModel, }
Expand description

VTable for language runtime plugins (Python, Julia, SQL, etc.).

Language runtimes enable fn <language> name(...) { body } blocks in Shape. The runtime compiles and invokes foreign language code, providing type marshaling between Shape values and native language objects.

Fields§

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

Initialize the runtime with MessagePack-encoded config. Returns: opaque instance pointer, or null on error.

§register_types: Option<unsafe extern "C" fn(instance: *mut c_void, types: *const u8, types_len: usize) -> i32>

Register Shape type schemas for stub generation (e.g. .pyi files). types_msgpack: MessagePack-encoded Vec<TypeSchemaExport>. Returns: 0 on success.

§compile: Option<unsafe extern "C" fn(instance: *mut c_void, name: *const u8, name_len: usize, source: *const u8, source_len: usize, param_names: *const u8, param_names_len: usize, param_types: *const u8, param_types_len: usize, return_type: *const u8, return_type_len: usize, is_async: bool, out_error: *mut *mut u8, out_error_len: *mut usize) -> *mut c_void>

Pre-compile a foreign function body.

  • name: function name (UTF-8)
  • source: dedented body text (UTF-8)
  • param_names_msgpack: MessagePack Vec<String> of parameter names
  • param_types_msgpack: MessagePack Vec<String> of Shape type names
  • return_type: Shape return type name (UTF-8, empty if none)
  • is_async: whether the function was declared async in Shape

Returns: opaque compiled function handle, or null on error. On error, writes a UTF-8 error message to out_error / out_error_len (caller frees via free_buffer).

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

Invoke a compiled function with MessagePack-encoded arguments.

args_msgpack: MessagePack-encoded argument array. On success, writes MessagePack-encoded result to out_ptr / out_len. Returns: 0 on success, non-zero on error.

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

Release a compiled function handle.

§language_id: Option<unsafe extern "C" fn(instance: *mut c_void) -> *const c_char>

Return the language identifier (null-terminated C string, e.g. “python”). The returned pointer must remain valid for the lifetime of the instance.

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

Return MessagePack-encoded LanguageRuntimeLspConfig. Caller frees via free_buffer.

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

Free a buffer allocated by compile/invoke/get_lsp_config.

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

Cleanup and destroy the runtime instance.

§error_model: ErrorModel

Error model for this language runtime.

Dynamic (0) means every call can fail at runtime — return values are automatically wrapped in Result<T>. Static (1) means the language has compile-time type safety and runtime errors are not expected.

Defaults to Dynamic (0) when zero-initialized.

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.