Why this shape
A rawreqwest::Client API is richer than a Sifr declaration should expose. Status codes, body bytes, header maps, and error variants all need a stable Sifr-facing shape. That adaptation belongs in a local bridge under src/bridges.
Four rules drive the reqwest path:
- Async Rust targets need
async def. Sifr rejects hiding a future behind a sync declaration. - Futures are
Sendby default. Current-thread-only futures need an explicit@rust.async(thread_affinity=tokio_current_thread)contract. - Bridges adapt; declarations stay typed. Convert Rust types into Sifr records or
Resultchannels in the bridge, then bind the bridge function with@rust(...). - No hidden runtimes or blocking. Sifr does not invent a Tokio runtime for you, and it rejects hiding
block_oninside an async path.
@rust(reqwest....) bindings are only for Rust items whose signatures already match Sifr. Prefer a bridge for HTTP.
Package setup
Cargo.toml
sifr.toml
sifr bridge check before you rely on the declaration in ordinary builds.
Write the bridge
src/bridges/http.rs
str in and Result[str, ...] out.
Declare and call
bridge.http.fetch_text resolves to your package-local module under
src/bridges. The nominal RustPanicError member reserves that error surface,
but current async code generation does not catch panics while polling the
returned Rust future. Do not rely on async panic containment here.
panic=map_error(path) is synchronous-only and is rejected on async def
until generated async panic wrappers receive runtime certification.
If you need status and body together, return a Sifr record from the bridge instead of a bare string:
What not to do
- Do not call blocking reqwest APIs from async Sifr without an explicit blocking offload annotation and workflow.
- Do not store borrowed response views across
awaitpoints. - Do not expect Sifr to start Tokio for you outside the package’s normal async runtime setup.
Next steps
- Full async, opaque-handle, and panic contracts: Rust Interop
- Simpler direct binding: blake3
- Structured async in Sifr: Async and Await
