pub struct WasmPluginBuilder<E: Any + Send + Sized + 'static> { /* private fields */ }
Expand description
Builder for creating WasmPlugin
.
Implementations§
Source§impl<S: Any + Send + Sized + 'static> WasmPluginBuilder<S>
impl<S: Any + Send + Sized + 'static> WasmPluginBuilder<S>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates new WasmPluginBuilder
.
Sourcepub fn new_with_store(store: Store) -> Self
pub fn new_with_store(store: Store) -> Self
Creates new WasmPluginBuilder
and overrides default store with custom.
Sourcepub fn from_binary(self, bytecode: &[u8]) -> Result<Self, CompileError>
Available on crate feature compiler
only.
pub fn from_binary(self, bytecode: &[u8]) -> Result<Self, CompileError>
compiler
only.Compiles bytecode with selected compiler. To change the compile use feature flags.
Default compiler is cranelift
.
Sourcepub unsafe fn from_serialized(
self,
data: &[u8],
) -> Result<Self, DeserializeError>
pub unsafe fn from_serialized( self, data: &[u8], ) -> Result<Self, DeserializeError>
Sourcepub unsafe fn from_serialized_compressed(
self,
compressed: &[u8],
) -> Result<Self, DeserializeError>
Available on crate feature flate2
only.
pub unsafe fn from_serialized_compressed( self, compressed: &[u8], ) -> Result<Self, DeserializeError>
flate2
only.Creates plugin from compressed bytes created by WasmPlugin::serialize_compress
.
§Safety
See Module::deserialize
.
Sourcepub unsafe fn from_serialized_file(
self,
path: impl AsRef<Path>,
) -> Result<Self, DeserializeError>
pub unsafe fn from_serialized_file( self, path: impl AsRef<Path>, ) -> Result<Self, DeserializeError>
Creates plugin from bytes created by WasmPlugin::serialize_to_file
.
§Safety
Sourcepub unsafe fn from_serialized_file_compressed(
self,
path: impl AsRef<Path>,
) -> Result<Self, DeserializeError>
Available on crate feature flate2
only.
pub unsafe fn from_serialized_file_compressed( self, path: impl AsRef<Path>, ) -> Result<Self, DeserializeError>
flate2
only.Creates plugin from compressed bytes created by WasmPlugin::serialize_to_file_compress
.
§Safety
See Module::deserialize
.
Sourcepub fn with_state(self, state: S) -> Self
pub fn with_state(self, state: S) -> Self
Creates a state that host function will have mutable access to.
You HAVE to create the state. If you do not need it simply pass ()
.
Sourcepub fn with_imports(
self,
imports: impl FnOnce(&mut Store, &FunctionEnv<WasmEnv<S>>) -> Imports,
) -> Self
pub fn with_imports( self, imports: impl FnOnce(&mut Store, &FunctionEnv<WasmEnv<S>>) -> Imports, ) -> Self
Creates imports i.e. host functions that guest imports.
use make_imports!
to create the closure.
Sourcepub fn with_exports(
self,
exports: impl IntoIterator<Item = Box<dyn GuestFunctionCreator>>,
) -> Self
pub fn with_exports( self, exports: impl IntoIterator<Item = Box<dyn GuestFunctionCreator>>, ) -> Self
Updates exports i.e. guest functions that host imports.
use make_exports!
to create the iterator.
Sourcepub fn finish(self) -> Result<WasmPlugin, InstantiationError>
pub fn finish(self) -> Result<WasmPlugin, InstantiationError>
Finishes building a WasmPlugin
.
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for WasmPluginBuilder<E>
impl<E> !RefUnwindSafe for WasmPluginBuilder<E>
impl<E> !Send for WasmPluginBuilder<E>
impl<E> !Sync for WasmPluginBuilder<E>
impl<E> Unpin for WasmPluginBuilder<E>where
E: Unpin,
impl<E> !UnwindSafe for WasmPluginBuilder<E>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more