pub struct WasmBuilder { /* private fields */ }
Expand description
The builder for building a wasm binary.
The builder itself is separated into multiple structs to make the setup type safe.
Building a wasm binary:
- Call
WasmBuilder::new
to create a new builder. - Select the project to build using the methods of
WasmBuilderSelectProject
. - Set additional
RUST_FLAGS
or a different name for the file containing the WASM code using methods ofWasmBuilder
. - Build the WASM binary using
Self::build
.
Implementations§
Source§impl WasmBuilder
impl WasmBuilder
Sourcepub fn new() -> WasmBuilderSelectProject
pub fn new() -> WasmBuilderSelectProject
Create a new instance of the builder.
Sourcepub fn export_heap_base(self) -> Self
pub fn export_heap_base(self) -> Self
Enable exporting __heap_base
as global variable in the WASM binary.
This adds -Clink-arg=--export=__heap_base
to RUST_FLAGS
.
Sourcepub fn set_file_name(self, file_name: impl Into<String>) -> Self
pub fn set_file_name(self, file_name: impl Into<String>) -> Self
Set the name of the file that will be generated in OUT_DIR
.
This file needs to be included to get access to the build WASM binary.
If this function is not called, file_name
defaults to wasm_binary.rs
Sourcepub fn import_memory(self) -> Self
pub fn import_memory(self) -> Self
Instruct the linker to import the memory into the WASM binary.
This adds -C link-arg=--import-memory
to RUST_FLAGS
.
Sourcepub fn append_to_rust_flags(self, flag: impl Into<String>) -> Self
pub fn append_to_rust_flags(self, flag: impl Into<String>) -> Self
Append the given flag
to RUST_FLAGS
.
flag
is appended as is, so it needs to be a valid flag.
Auto Trait Implementations§
impl Freeze for WasmBuilder
impl RefUnwindSafe for WasmBuilder
impl Send for WasmBuilder
impl Sync for WasmBuilder
impl Unpin for WasmBuilder
impl UnwindSafe for WasmBuilder
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