Struct wiggle::wasmtime_crate::Engine
source · [−]pub struct Engine { /* private fields */ }
Expand description
An Engine
which is a global context for compilation and management of wasm
modules.
An engine can be safely shared across threads and is a cheap cloneable handle to the actual engine. The engine itself will be deallocated once all references to it have gone away.
Engines store global configuration preferences such as compilation settings, enabled features, etc. You’ll likely only need at most one of these for a program.
Engines and Clone
Using clone
on an Engine
is a cheap operation. It will not create an
entirely new engine, but rather just a new reference to the existing engine.
In other words it’s a shallow copy, not a deep copy.
Engines and Default
You can create an engine with default configuration settings using
Engine::default()
. Be sure to consult the documentation of Config
for
default settings.
Implementations
sourceimpl Engine
impl Engine
sourcepub fn new(config: &Config) -> Result<Engine, Error>
pub fn new(config: &Config) -> Result<Engine, Error>
Creates a new Engine
with the specified compilation and
configuration settings.
sourcepub fn tls_eager_initialize() -> Result<(), Trap>
pub fn tls_eager_initialize() -> Result<(), Trap>
Eagerly initialize thread-local functionality shared by all Engine
s.
Wasmtime’s implementation on some platforms may involve per-thread setup that needs to happen whenever WebAssembly is invoked. This setup can take on the order of a few hundred microseconds, whereas the overhead of calling WebAssembly is otherwise on the order of a few nanoseconds. This setup cost is paid once per-OS-thread. If your application is sensitive to the latencies of WebAssembly function calls, even those that happen first on a thread, then this function can be used to improve the consistency of each call into WebAssembly by explicitly frontloading the cost of the one-time setup per-thread.
Note that this function is not required to be called in any embedding. Wasmtime will automatically initialize thread-local-state as necessary on calls into WebAssembly. This is provided for use cases where the latency of WebAssembly calls are extra-important, which is not necessarily true of all embeddings.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more