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

Method finish_append_submodule

crates/rust/src/interface.rs:444–480  ·  view source on GitHub ↗
(mut self, snake: &str, module_path: Vec<String>, docs: &Docs)

Source from the content-addressed store, hash-verified

442 }
443
444 pub fn finish_append_submodule(mut self, snake: &str, module_path: Vec<String>, docs: &Docs) {
445 let module = self.finish();
446
447 self.rustdoc(docs);
448 let docs = mem::take(&mut self.src).to_string();
449 let docs = docs.trim_end();
450
451 let path_to_root = self.path_to_root();
452 let used_static = if self.r#gen.opts.disable_custom_section_link_helpers {
453 String::new()
454 } else {
455 format!(
456 "\
457 #[used]
458 #[doc(hidden)]
459 static __FORCE_SECTION_REF: fn() =
460 {path_to_root}__link_custom_section_describing_imports;
461 "
462 )
463 };
464 let module = format!(
465 "\
466 {docs}
467 #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)]
468 pub mod {snake} {{
469 {used_static}
470 {module}
471 }}
472",
473 );
474 let map = if self.in_import {
475 &mut self.r#gen.import_modules
476 } else {
477 &mut self.r#gen.export_modules
478 };
479 map.push((module, module_path))
480 }
481
482 fn generate_payloads(&mut self, prefix: &str, func: &Function, interface: Option<&WorldKey>) {
483 let old_identifier = mem::replace(&mut self.identifier, Identifier::StreamOrFuturePayload);

Callers 2

import_interfaceMethod · 0.80
export_interfaceMethod · 0.80

Calls 6

newFunction · 0.85
rustdocMethod · 0.80
path_to_rootMethod · 0.80
finishMethod · 0.45
to_stringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected