MoonBitComponent

Struct MoonBitComponent 

Source
pub struct MoonBitComponent { /* private fields */ }

Implementations§

Source§

impl MoonBitComponent

Source

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.

Source

pub fn disable_cleanup(&mut self)

Disables cleaning up the temporary directory, for debugging purposes.

Source

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.

Source

pub fn define_bindgen_packages(&mut self) -> Result<()>

Defines the MoonBit packages implementing the WIT bindings

Source

pub fn set_warning_control( &mut self, package_name: &str, warning_control: Vec<WarningControl>, ) -> Result<()>

Source

pub fn set_alert_control( &mut self, package_name: &str, alert_control: Vec<WarningControl>, ) -> Result<()>

Source

pub fn define_package(&mut self, package: MoonBitPackage)

Defines a custom MoonBit package

Source

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.

Source

pub fn write_file(&self, relative_path: &Utf8Path, contents: &str) -> Result<()>

Source

pub fn write_world_stub(&self, moonbit_source: &str) -> Result<()>

Writes the top level export stub for the selected world

Source

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.

Source

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.

Source

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.

Source

pub fn moonbit_root_package(&self) -> Result<String>

Source

pub fn root_pkg_namespace(&self) -> Result<String>

Source

pub fn root_pkg_name(&self) -> Result<String>

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.