Struct spin_core::EngineBuilder
source · pub struct EngineBuilder<T> { /* private fields */ }Expand description
A builder interface for configuring a new Engine.
A new EngineBuilder can be obtained with Engine::builder.
Implementations§
source§impl<T: Send + Sync> EngineBuilder<T>
impl<T: Send + Sync> EngineBuilder<T>
sourcepub fn link_import(
&mut self,
f: impl FnOnce(&mut Linker<T>, fn(_: &mut Data<T>) -> &mut T) -> Result<()>
) -> Result<()>
pub fn link_import(
&mut self,
f: impl FnOnce(&mut Linker<T>, fn(_: &mut Data<T>) -> &mut T) -> Result<()>
) -> Result<()>
Adds definition(s) to the built Engine.
This method’s signature is meant to be used with
wit-bindgen’s
generated add_to_linker functions, e.g.:
wit_bindgen_wasmtime::import!({paths: ["my-interface.wit"], async: *});
// ...
let mut builder: EngineBuilder<my_interface::MyInterfaceData> = Engine::builder();
builder.link_import(my_interface::MyInterface::add_to_linker)?;sourcepub fn add_host_component<HC: HostComponent + Send + Sync + 'static>(
&mut self,
host_component: HC
) -> Result<HostComponentDataHandle<HC>>
pub fn add_host_component<HC: HostComponent + Send + Sync + 'static>(
&mut self,
host_component: HC
) -> Result<HostComponentDataHandle<HC>>
Adds a HostComponent to the built Engine.
Returns a HostComponentDataHandle which can be passed to
HostComponentsData to access or set associated
HostComponent::Data for an instance.
sourcepub fn epoch_tick_interval(&mut self, interval: Duration)
pub fn epoch_tick_interval(&mut self, interval: Duration)
Sets the epoch tick internal for the built Engine.
This is used by Store::set_deadline to calculate the number of
“ticks” for epoch interruption, and by the default epoch ticker thread.
The default is DEFAULT_EPOCH_TICK_INTERVAL.
See EngineBuilder::epoch_ticker_thread and
wasmtime::Config::epoch_interruption.
sourcepub fn epoch_ticker_thread(&mut self, enable: bool)
pub fn epoch_ticker_thread(&mut self, enable: bool)
Configures whether the epoch ticker thread will be spawned when this
Engine is built.
Enabled by default; if disabled, the user must arrange to call
engine.as_ref().increment_epoch() every epoch_tick_interval or
interrupt-based features like Store::set_deadline will not work.
sourcepub fn build_with_data(self, instance_pre_data: T) -> Engine<T>
pub fn build_with_data(self, instance_pre_data: T) -> Engine<T>
Builds an Engine from this builder with the given host state data.
Note that this data will generally go entirely unused, but is needed
by the implementation of Engine::instantiate_pre. If T: Default,
it is probably preferable to use EngineBuilder::build.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for EngineBuilder<T>
impl<T> Send for EngineBuilder<T>
impl<T> Sync for EngineBuilder<T>
impl<T> Unpin for EngineBuilder<T>
impl<T> !UnwindSafe for EngineBuilder<T>
Blanket Implementations§
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.