pub struct WasmLoader { /* private fields */ }Expand description
Top-level WASM Component Model plugin loader.
Implementations§
Source§impl WasmLoader
impl WasmLoader
Sourcepub fn with_http(self, http: Arc<dyn HttpEgress>) -> Self
pub fn with_http(self, http: Arc<dyn HttpEgress>) -> Self
Attach an HTTP egress backing the host-net interface (builder style).
Sourcepub fn prepare(
&self,
manifest_json: &[u8],
grants: &CapabilitySet,
) -> Result<PreparedComponent, WasmError>
pub fn prepare( &self, manifest_json: &[u8], grants: &CapabilitySet, ) -> Result<PreparedComponent, WasmError>
Parse a CM-plugin manifest and intersect declared/granted capabilities. Deterministic — no wasmtime instantiation.
§Errors
WasmError::InvalidWasmif the JSON doesn’t parse.
Sourcepub fn prepare_parsed(
&self,
manifest: ComponentManifest,
grants: &CapabilitySet,
) -> PreparedComponent
pub fn prepare_parsed( &self, manifest: ComponentManifest, grants: &CapabilitySet, ) -> PreparedComponent
Intersect declared/granted capabilities for an already-parsed manifest, skipping the JSON round-trip.
Self::load reads the manifest export off a bootstrap instance
(parsed ComponentManifest), then needs the cap-intersection
result. The previous implementation re-serialized the parsed
struct to JSON and called Self::prepare which deserialized it
straight back — a wasteful round-trip whose only purpose was
reusing the cap-intersection loop. This entry point preserves the
loop and skips the (de)serialization.
Sourcepub fn instantiate(
&self,
bytes: &[u8],
prepared: &PreparedComponent,
) -> Result<ScalarPluginInstance, WasmError>
pub fn instantiate( &self, bytes: &[u8], prepared: &PreparedComponent, ) -> Result<ScalarPluginInstance, WasmError>
Instantiate a CM plugin into a fresh ScalarPluginInstance.
Used directly only by tests; production code goes through
Self::load which two-passes the manifest negotiation.
§Errors
WasmError::InvalidWasmon Component compilation failure.WasmError::Instantiateon linker / instantiation failure.
Sourcepub fn load(
&self,
bytes: &[u8],
host_grants: &CapabilitySet,
registrar: &mut PluginRegistrar<'_>,
) -> Result<LoadOutcome, WasmError>
pub fn load( &self, bytes: &[u8], host_grants: &CapabilitySet, registrar: &mut PluginRegistrar<'_>, ) -> Result<LoadOutcome, WasmError>
End-to-end load: read manifest, intersect with host grants, rebuild with effective caps, read register export, register scalar adapters with the supplied registrar.
§Errors
See Self::instantiate + manifest / register parse failures.
Sourcepub fn load_as_plugin(
&self,
bytes: &[u8],
host_grants: &CapabilitySet,
) -> Result<Box<dyn Plugin + Send + Sync>, WasmError>
pub fn load_as_plugin( &self, bytes: &[u8], host_grants: &CapabilitySet, ) -> Result<Box<dyn Plugin + Send + Sync>, WasmError>
Load a component and present it as a uni_plugin::Plugin.
Unlike Self::load — which registers adapters directly into a
caller-supplied registrar — this returns a self-contained Plugin
whose uni_plugin::Plugin::manifest is synthesized from the
component’s manifest and whose uni_plugin::Plugin::register replays
the component’s register entries. It is the bridge the conformance
harness (uni_plugin_conformance::WasmConformanceLoader) needs to run
the same probe suite against a real component as against a live-Rust
plugin.
The returned plugin owns the warm scalar pool plus the component bytes
and negotiated capabilities, so register can rebuild
aggregate/procedure pools and is safely re-runnable (the conformance
idempotency probe registers twice).
§Errors
See Self::load — manifest / register parse + instantiation failures,
plus WasmError::InvalidWasm if the manifest version is not semver.
Trait Implementations§
Source§impl Debug for WasmLoader
impl Debug for WasmLoader
Source§impl Default for WasmLoader
impl Default for WasmLoader
Source§fn default() -> WasmLoader
fn default() -> WasmLoader
Auto Trait Implementations§
impl !RefUnwindSafe for WasmLoader
impl !UnwindSafe for WasmLoader
impl Freeze for WasmLoader
impl Send for WasmLoader
impl Sync for WasmLoader
impl Unpin for WasmLoader
impl UnsafeUnpin for WasmLoader
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
self file descriptor. Read moreSource§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