Expand description
Non-blocking / streaming HTTP fetch for Oxide guest modules.
The legacy api_fetch import (in crate::capabilities) blocks the guest
until the entire response body has been downloaded. That prevents guests
from rendering frames during large downloads and makes LLM-style
token-streaming, chunked feeds, or progressive image loads impossible.
This module exposes a second fetch API that is fully async from the guest’s
perspective. The shape mirrors crate::websocket:
api_fetch_begindispatches a request and returns a handle immediately.api_fetch_state/api_fetch_statusreport progress.api_fetch_recvpulls the next body chunk from an in-memory queue.api_fetch_abortcancels an in-flight request.api_fetch_removefrees host-side resources once the guest is done.
A background tokio task per request drives reqwest’s bytes_stream(),
pushing chunks into a VecDeque<Vec<u8>> drained by the guest.
Structs§
- Fetch
State - All streaming-fetch state for a host. Lazily initialised on the first
api_fetch_begincall.
Constants§
- FETCH_
ABORTED - Request was aborted by the guest.
- FETCH_
DONE - Body fully delivered and the queue may still contain trailing chunks.
- FETCH_
ERROR - Request failed. Use
api_fetch_errorto retrieve the message. - FETCH_
PENDING - Request dispatched; waiting for response headers.
- FETCH_
STREAMING - Headers received; body chunks may be streaming in.
Functions§
- register_
fetch_ functions - Register all
api_fetch_*streaming host functions on the given linker.