pub struct MoonBit { /* private fields */ }Trait Implementations§
Source§impl WorldGenerator for MoonBit
World generator implementation for MoonBit.
impl WorldGenerator for MoonBit
World generator implementation for MoonBit.
This implementation connects the generic wit-bindgen world generation
workflow with MoonBit-specific codegen details. It consumes the parsed
WIT Resolve structure and emits MoonBit source (*.mbt) and package
metadata files into the provided Files collection.
Responsibilities and behavior:
preprocess: Initialize generator-wide state (package resolver, project name, and size/align information) for the current world.import_interface/export_interface: Generate per-interface sources, FFI glue, README documentation andmoon.pkg.jsonmetadata.import_funcs/export_funcs/import_types: Collect and accumulate world-level functions and types (the$rootmodule) into fragments that are later written out byfinish_importsorfinish.finish_imports/finish: Emit aggregated import artifacts and the final project entrypoints such as the combined FFI module and package descriptor files.
Implementation notes:
- Namespacing and collision avoidance are handled using
PkgResolverand an internalNsto make import/export package names stable even when multiple package versions are present. - Inline FFI helpers and builtins are collected and written once into the final export FFI module. Async helpers are emitted when required.
fn preprocess(&mut self, resolve: &Resolve, world: WorldId)
fn import_interface( &mut self, resolve: &Resolve, key: &WorldKey, id: InterfaceId, files: &mut Files, ) -> Result<()>
fn import_funcs( &mut self, resolve: &Resolve, world: WorldId, funcs: &[(&str, &Function)], _files: &mut Files, )
fn import_types( &mut self, resolve: &Resolve, world: WorldId, types: &[(&str, TypeId)], _files: &mut Files, )
fn finish_imports( &mut self, resolve: &Resolve, world: WorldId, files: &mut Files, )
fn export_interface( &mut self, resolve: &Resolve, key: &WorldKey, id: InterfaceId, files: &mut Files, ) -> Result<()>
fn export_funcs( &mut self, resolve: &Resolve, world: WorldId, funcs: &[(&str, &Function)], files: &mut Files, ) -> Result<()>
fn finish( &mut self, _resolve: &Resolve, _id: WorldId, files: &mut Files, ) -> Result<()>
fn generate( &mut self, resolve: &mut Resolve, id: Id<World>, files: &mut Files, ) -> Result<(), Error>
Source§fn uses_nominal_type_ids(&self) -> bool
fn uses_nominal_type_ids(&self) -> bool
Whether or not this bindings generator expects
Resolve::generate_nominal_type_ids to be used before generating
bindings.Auto Trait Implementations§
impl Freeze for MoonBit
impl RefUnwindSafe for MoonBit
impl Send for MoonBit
impl Sync for MoonBit
impl Unpin for MoonBit
impl UnsafeUnpin for MoonBit
impl UnwindSafe for MoonBit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more