pub struct MoonBitComponent { /* private fields */ }Implementations§
Source§impl MoonBitComponent
 
impl MoonBitComponent
Sourcepub fn empty_from_wit(
    wit: impl AsRef<str>,
    selected_world: Option<&str>,
) -> Result<Self>
 
pub fn empty_from_wit( wit: impl AsRef<str>, selected_world: Option<&str>, ) -> Result<Self>
Initializes a new MoonBit component that implements the given WIT interface.
This step will create a temporary directory and generate MoonBit WIT bindings in it.
Sourcepub fn disable_cleanup(&mut self)
 
pub fn disable_cleanup(&mut self)
Disables cleaning up the temporary directory, for debugging purposes.
Sourcepub fn existing(path: &Utf8Path, selected_world: Option<&str>) -> Result<Self>
 
pub fn existing(path: &Utf8Path, selected_world: Option<&str>) -> Result<Self>
Initializes a new MoonBit component from an existing directory with a valid ‘wit’ directory in it.
The existing directory is expected to have the WIT bindings already generated.
Sourcepub fn define_bindgen_packages(&mut self) -> Result<()>
 
pub fn define_bindgen_packages(&mut self) -> Result<()>
Defines the MoonBit packages implementing the WIT bindings
pub fn set_warning_control( &mut self, package_name: &str, warning_control: Vec<WarningControl>, ) -> Result<()>
pub fn set_alert_control( &mut self, package_name: &str, alert_control: Vec<WarningControl>, ) -> Result<()>
Sourcepub fn define_package(&mut self, package: MoonBitPackage)
 
pub fn define_package(&mut self, package: MoonBitPackage)
Defines a custom MoonBit package
Sourcepub fn add_dependency(
    &mut self,
    package_name: &str,
    mi_path: &Utf8Path,
    alias: &str,
) -> Result<()>
 
pub fn add_dependency( &mut self, package_name: &str, mi_path: &Utf8Path, alias: &str, ) -> Result<()>
Defines an additional dependency for a MoonBit package previously added with define_package.
pub fn write_file(&self, relative_path: &Utf8Path, contents: &str) -> Result<()>
Sourcepub fn write_world_stub(&self, moonbit_source: &str) -> Result<()>
 
pub fn write_world_stub(&self, moonbit_source: &str) -> Result<()>
Writes the top level export stub for the selected world
Sourcepub fn write_interface_stub(
    &self,
    package_name: &PackageName,
    interface_name: &str,
    moonbit_source: &str,
) -> Result<()>
 
pub fn write_interface_stub( &self, package_name: &PackageName, interface_name: &str, moonbit_source: &str, ) -> Result<()>
Writes the interface stub for a given package and interface name.
Sourcepub fn write_interface_package_json(
    &self,
    package_name: &PackageName,
    interface_name: &str,
    json: Value,
) -> Result<()>
 
pub fn write_interface_package_json( &self, package_name: &PackageName, interface_name: &str, json: Value, ) -> Result<()>
Writes the MoonBit package JSON file for a given exported package and interface name.
Sourcepub fn build(
    &self,
    main_package_name: Option<&str>,
    target: &Utf8Path,
) -> Result<()>
 
pub fn build( &self, main_package_name: Option<&str>, target: &Utf8Path, ) -> Result<()>
Builds the MoonBit component, compiling all packages and linking them together into a final WASM component.
The main_package_name is optional, if it is not provided, the binding generator’s gen package will be used as the main package.