MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / print_export_sig

Method print_export_sig

crates/rust/src/interface.rs:1289–1314  ·  view source on GitHub ↗
(&mut self, func: &Function, async_: bool)

Source from the content-addressed store, hash-verified

1287 }
1288
1289 fn print_export_sig(&mut self, func: &Function, async_: bool) -> Vec<String> {
1290 self.src.push_str("(");
1291 let variant = if async_ {
1292 AbiVariant::GuestExportAsync
1293 } else {
1294 AbiVariant::GuestExport
1295 };
1296 let sig = self.resolve.wasm_signature(variant, func);
1297 let mut params = Vec::new();
1298 for (i, param) in sig.params.iter().enumerate() {
1299 let name = format!("arg{i}");
1300 uwrite!(self.src, "{name}: {},", wasm_type(*param));
1301 params.push(name);
1302 }
1303 self.src.push_str(")");
1304
1305 match sig.results.len() {
1306 0 => {}
1307 1 => {
1308 uwrite!(self.src, " -> {}", wasm_type(sig.results[0]));
1309 }
1310 _ => unimplemented!(),
1311 }
1312
1313 params
1314 }
1315
1316 fn print_post_return_sig(&mut self, func: &Function) -> Vec<String> {
1317 self.src.push_str("(");

Callers 2

generate_guest_exportMethod · 0.80

Calls 4

newFunction · 0.85
push_strMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected