2026-07-30 08:13:24 +08:00
|
|
|
//! Smallest request/response Component example: it returns input bytes unchanged.
|
|
|
|
|
|
2026-07-27 04:59:33 +08:00
|
|
|
mod bindings {
|
2026-07-30 08:13:24 +08:00
|
|
|
// Generate the guest trait and export adapter from the selected WIT world.
|
|
|
|
|
// Dependency sync must populate `wit/deps` before this macro is compiled.
|
2026-07-27 04:59:33 +08:00
|
|
|
wit_bindgen::generate!({
|
|
|
|
|
path: "wit",
|
|
|
|
|
world: "echo-component",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Echo;
|
|
|
|
|
|
|
|
|
|
impl bindings::Guest for Echo {
|
|
|
|
|
fn init(_config: Vec<u8>) -> Result<(), bindings::ServiceError> {
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn invoke(input: Vec<u8>) -> Result<Vec<u8>, bindings::ServiceError> {
|
|
|
|
|
Ok(input)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bindings::export!(Echo with_types_in bindings);
|