Struct wizer::Wizer [−][src]
Wizer: the WebAssembly pre-initializer!
Don’t wait for your Wasm module to initialize itself, pre-initialize it! Wizer instantiates your WebAssembly module, executes its initialization function, and then serializes the instance’s initialized state out into a new WebAssembly module. Now you can use this new, pre-initialized WebAssembly module to hit the ground running, without making your users wait for that first-time set up code to complete.
Caveats
-
The initialization function may not call any imported functions. Doing so will trigger a trap and
wizer
will exit. -
The Wasm module may not import globals, tables, or memories.
-
Reference types are not supported yet. This is tricky because it would allow the Wasm module to mutate tables, and we would need to be able to diff the initial table state with the new table state, but funcrefs and externrefs aren’t comparable in the Wasm spec, which makes diffing problematic.
Implementations
impl Wizer
[src]
pub fn new() -> Self
[src]
Construct a new Wizer
builder.
pub fn init_func(&mut self, init_func: impl Into<String>) -> &mut Self
[src]
The export name of the initializer function.
Defaults to "wizer.initialize"
.
pub fn func_rename(
&mut self,
new_name: impl Display,
old_name: impl Display
) -> &mut Self
[src]
&mut self,
new_name: impl Display,
old_name: impl Display
) -> &mut Self
Add a function rename to perform.
pub fn allow_wasi(&mut self, allow: bool) -> &mut Self
[src]
Allow WASI imports to be called during initialization?
This can introduce diverging semantics because the initialization can observe nondeterminism that might have gone a different way at runtime than it did at initialization time.
If your Wasm module uses WASI’s get_random
to add randomness to
something as a security mitigation (e.g. something akin to ASLR or the
way Rust’s hash maps incorporate a random nonce) then note that, if the
randomization is added during initialization time and you don’t ever
re-randomize at runtime, then that randomization will become per-module
rather than per-instance.
Defaults to false
.
pub fn wasm_multi_memory(&mut self, enable: bool) -> &mut Self
[src]
Enable or disable the Wasm multi-memory proposal.
Defaults to true
.
pub fn wasm_multi_value(&mut self, enable: bool) -> &mut Self
[src]
Enable or disable the Wasm multi-value proposal.
Defaults to true
.
pub fn run(&self, wasm: &[u8]) -> Result<Vec<u8>>
[src]
Initialize the given Wasm, snapshot it, and return the serialized snapshot as a new, pre-initialized Wasm module.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Wizer
impl Send for Wizer
impl Sync for Wizer
impl Unpin for Wizer
impl UnwindSafe for Wizer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Pointee for T
type Pointer = u32
pub fn debug(
pointer: <T as Pointee>::Pointer,
f: &mut Formatter<'_>
) -> Result<(), Error>
pointer: <T as Pointee>::Pointer,
f: &mut Formatter<'_>
) -> Result<(), Error>
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,