Skip to main content

ModuleExports

Struct ModuleExports 

Source
pub struct ModuleExports {
    pub name: String,
    pub description: String,
    pub exports: HashMap<String, ModuleFn>,
    pub async_exports: HashMap<String, AsyncModuleFn>,
    pub schemas: HashMap<String, ModuleFunction>,
    pub export_visibility: HashMap<String, ModuleExportVisibility>,
    pub shape_sources: Vec<(String, String)>,
    pub module_artifacts: Vec<ModuleArtifact>,
    pub method_intrinsics: HashMap<String, HashMap<String, ModuleFn>>,
    pub type_schemas: Vec<TypeSchema>,
}
Expand description

A Rust-implemented module exposed via <name>.

Fields§

§name: String

Module name (e.g., “csv”, “json”, “duckdb”)

§description: String

Human-readable description of this module

§exports: HashMap<String, ModuleFn>

Exported sync functions: name → implementation

§async_exports: HashMap<String, AsyncModuleFn>

Exported async functions: name → implementation

§schemas: HashMap<String, ModuleFunction>

Function schemas for LSP + validation: name → schema

§export_visibility: HashMap<String, ModuleExportVisibility>

Export visibility controls: name → visibility.

§shape_sources: Vec<(String, String)>

Shape source files bundled with this extension. Compiled and merged with core stdlib at startup. Vec of (filename, source_code) pairs.

Legacy compatibility field. New code should use module_artifacts.

§module_artifacts: Vec<ModuleArtifact>

Bundled module artifacts (source/compiled/both).

§method_intrinsics: HashMap<String, HashMap<String, ModuleFn>>

Method intrinsics for fast dispatch on typed Objects. Outer key: type name (e.g., “DuckDbQuery”) Inner key: method name (e.g., “build_sql”) Dispatched BEFORE callable-property and UFCS fallback.

§type_schemas: Vec<TypeSchema>

Type schemas to register in the VM’s runtime TypeSchemaRegistry. Extensions can use this to declare types that the runtime can use for TypedObject creation and field validation.

Implementations§

Source§

impl ModuleExports

Source

pub fn new(name: impl Into<String>) -> Self

Create a new extension module.

Source

pub fn add_function<F>(&mut self, name: impl Into<String>, f: F) -> &mut Self
where F: for<'ctx> Fn(&[ValueWord], &ModuleContext<'ctx>) -> Result<ValueWord, String> + Send + Sync + 'static,

Register an exported function.

Source

pub fn add_function_with_schema<F>( &mut self, name: impl Into<String>, f: F, schema: ModuleFunction, ) -> &mut Self
where F: for<'ctx> Fn(&[ValueWord], &ModuleContext<'ctx>) -> Result<ValueWord, String> + Send + Sync + 'static,

Register an exported function with its schema.

Source

pub fn add_async_function<F, Fut>( &mut self, name: impl Into<String>, f: F, ) -> &mut Self
where F: Fn(Vec<ValueWord>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<ValueWord, String>> + Send + 'static,

Register an async exported function.

Source

pub fn add_async_function_with_schema<F, Fut>( &mut self, name: impl Into<String>, f: F, schema: ModuleFunction, ) -> &mut Self
where F: Fn(Vec<ValueWord>) -> Fut + Send + Sync + 'static, Fut: Future<Output = Result<ValueWord, String>> + Send + 'static,

Register an async exported function with its schema.

Source

pub fn set_export_visibility( &mut self, name: impl Into<String>, visibility: ModuleExportVisibility, ) -> &mut Self

Set visibility for one export name.

Source

pub fn export_visibility(&self, name: &str) -> ModuleExportVisibility

Resolve visibility for one export (defaults to Public).

Source

pub fn is_export_available(&self, name: &str, comptime_mode: bool) -> bool

Return true when the export can be called in the current compiler mode.

Source

pub fn is_export_public_surface(&self, name: &str, comptime_mode: bool) -> bool

Return true when the export should appear in user-facing completion/hover surfaces.

Source

pub fn export_names_available(&self, comptime_mode: bool) -> Vec<&str>

List exports available for the requested mode (sync + async).

Source

pub fn export_names_public_surface(&self, comptime_mode: bool) -> Vec<&str>

List user-facing exports for completion/hover (sync + async).

Source

pub fn add_shape_source(&mut self, filename: &str, source: &str) -> &mut Self

Bundle a Shape source file with this extension. The source will be compiled and merged with stdlib at startup.

Source

pub fn add_shape_artifact( &mut self, module_path: impl Into<String>, source: Option<String>, compiled: Option<Vec<u8>>, ) -> &mut Self

Register a bundled module artifact (source/compiled/both).

Source

pub fn add_intrinsic<F>( &mut self, type_name: &str, method_name: &str, f: F, ) -> &mut Self
where F: for<'ctx> Fn(&[ValueWord], &ModuleContext<'ctx>) -> Result<ValueWord, String> + Send + Sync + 'static,

Register a method intrinsic for fast dispatch on typed Objects. Called before callable-property and UFCS fallback in handle_object_method().

Source

pub fn add_type_schema(&mut self, schema: TypeSchema) -> SchemaId

Register a type schema that the VM will add to its runtime registry. Returns the schema ID for reference.

Source

pub fn has_export(&self, name: &str) -> bool

Check if this module exports a given name (sync or async).

Source

pub fn get_export(&self, name: &str) -> Option<&ModuleFn>

Get a sync exported function by name.

Source

pub fn get_async_export(&self, name: &str) -> Option<&AsyncModuleFn>

Get an async exported function by name.

Source

pub fn is_async(&self, name: &str) -> bool

Check if a function is async.

Source

pub fn get_schema(&self, name: &str) -> Option<&ModuleFunction>

Get the schema for an exported function.

Source

pub fn export_names(&self) -> Vec<&str>

List all export names (sync + async).

Source

pub fn to_parsed_schema(&self) -> ParsedModuleSchema

Convert this module’s schema to a ParsedModuleSchema for the semantic analyzer, mirroring the conversion in BytecodeExecutor::module_schemas().

Source

pub fn stdlib_module_schemas() -> Vec<ParsedModuleSchema>

Return ParsedModuleSchema entries for all shipped native stdlib modules. Used during engine initialization to make these globals visible at compile time.

Trait Implementations§

Source§

impl Clone for ModuleExports

Source§

fn clone(&self) -> ModuleExports

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModuleExports

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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