Skip to main content

host_fetch

Function host_fetch 

Source
pub fn host_fetch(url: &str) -> Result<Vec<u8>, NetworkFailure>
Expand description

Fetches the response body for an HTTP GET request to url, via the host’s fetch capability.

This only links and behaves correctly when compiled as part of a wasm32 component instantiated by a host implementing the host interface’s fetch function (see wit/data-provider.wit) — it has no behavior of its own independent of that generated import. Callers should gate use of it behind #[cfg(target_arch = "wasm32")] and keep a separate, injectable seam for native unit/integration tests.

§Errors

Returns NetworkFailure if the host reports the request failed (network error, non-2xx status, or a plugin-manifest network-host restriction).