Skip to main content

ModuleExports

Struct ModuleExports 

Source
pub struct ModuleExports {
    pub name: String,
    pub description: String,
    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>,
    pub typed_exports: TypedModuleExports,
}
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

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

§typed_exports: TypedModuleExports

Typed-return ABI registry (Phase 4b).

Authoritative registry for native-module function bodies. Every export here declares its return type via crate::typed_module_exports::TypedReturn / crate::typed_module_exports::ConcreteType; the kind-threaded marshal layer projects the typed return into a kinded slot at the dispatch boundary inside the VM, not in the body (ADR-006 §2.7). Phase 4c.4 deleted the legacy exports/async_exports ModuleFn parallel registry — every callable function body lives here.

Implementations§

Source§

impl ModuleExports

Source

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

Create a new extension module.

Source

pub fn typed_exports_mut(&mut self) -> &mut TypedModuleExports

Mutable access to the typed-return registry. Used by crate::typed_module_exports::register_typed_function to record the typed-body entry.

Source

pub fn typed_exports(&self) -> &TypedModuleExports

Read-only access to the typed-return registry.

Source

pub fn add_schema_only( &mut self, name: impl Into<String>, schema: ModuleFunction, ) -> &mut Self

Register only the LSP/validation schema and visibility for an exported name. The actual function body lives in typed_exports and is dispatched directly via ModuleFnEntry::Typed / ModuleFnEntry::TypedAsync — see register_typed_function/register_typed_async_function and the test-only register_test_function* helpers.

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(&[KindedSlot], &ModuleContext<'ctx>) -> Result<KindedSlot, 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 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 (const: unstable) · 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> 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