pub struct Engine { /* private fields */ }Expand description
Shared wasmtime::Engine plus a background thread that ticks the epoch
counter so per-store wall-clock deadlines can fire.
One Engine per process is enough; cloning a Plugin reuses the engine.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new() -> Result<Self, EngineError>
pub fn new() -> Result<Self, EngineError>
Build an engine with no on-disk compilation cache. Every plugin is recompiled from scratch on load. Used by tests and the harness where a shared cache directory would add cross-run coupling.
Sourcepub fn with_cache(cache_dir: &Path) -> Result<Self, EngineError>
pub fn with_cache(cache_dir: &Path) -> Result<Self, EngineError>
Build an engine backed by wasmtime’s on-disk compilation cache rooted
at cache_dir. Compiling a plugin component (Plugin::load_*) is the
dominant per-invocation cost — hundreds of milliseconds of Cranelift
codegen for a multi-MB plugin — and it is pure: a function of the wasm
bytes, the compiler config, and the wasmtime version. The cache keys on
exactly those, so a second forge run (or a sibling process in a
parallel regen) deserialises the prior artifact in single-digit
milliseconds instead of recompiling.
Cache hits never change generated output: the cached entry is the same machine code Cranelift would have produced, and wasmtime’s own version/config fingerprint invalidates stale entries (a wasmtime bump simply misses and recompiles).
pub fn raw(&self) -> &WtEngine
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Engine
impl !UnwindSafe for Engine
impl Freeze for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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