xref: /wasmtime-44.0.1/crates/test-programs/src/bin/p3_cli_serve_hello_world.rs (revision fee9be21)
  • Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use test_programs::p3::wasi::http::types::{ErrorCode, Fields, Request, Response};
2 use test_programs::p3::{proxy, wit_future, wit_stream};
3 
4 struct T;
5 
6 proxy::export!(T);
7 
8 impl proxy::exports::wasi::http::handler::Guest for T {
9     async fn handle(_request: Request) -> Result<Response, ErrorCode> {
10         let (mut body_tx, body_rx) = wit_stream::new();
11         let (body_result_tx, body_result_rx) = wit_future::new(|| Ok(None));
12         let (response, _future_result) =
13             Response::new(Fields::new(), Some(body_rx), body_result_rx);
14         drop(body_result_tx);
15 
16         wit_bindgen::spawn(async move {
17             let remaining = body_tx.write_all(b"Hello, WASI!".to_vec()).await;
18             assert!(remaining.is_empty());
19         });
20         Ok(response)
21     }
22 }
23 
24 fn main() {
25     unreachable!()
26 }
27 

served by {OpenGrok

Last Index Update: Fri May 15 20:09:11 GMT 2026