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
[wasmtime::component::bindgen
]’s generated add_to_linker
functions, e.g.:
use spin_core::my_interface;
// ...
let mut builder: EngineBuilder<my_interface::MyInterfaceData> = Engine::builder();
builder.link_import(my_interface::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.
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§
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<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
source§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.source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self
file descriptor. Read more