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

Method name_interface

crates/rust/src/lib.rs:460–506  ·  view source on GitHub ↗
(
        &mut self,
        resolve: &Resolve,
        id: InterfaceId,
        name: &WorldKey,
        is_export: bool,
    )

Source from the content-addressed store, hash-verified

458 }
459
460 fn name_interface(
461 &mut self,
462 resolve: &Resolve,
463 id: InterfaceId,
464 name: &WorldKey,
465 is_export: bool,
466 ) -> Result<bool> {
467 let with_name = resolve.name_world_key(name);
468 let remapping = if is_export {
469 &TypeGeneration::Generate
470 } else {
471 match self.with.get(&with_name) {
472 Some(remapping) => remapping,
473 None => bail!(MissingWith(with_name)),
474 }
475 };
476 self.generated_types.insert(with_name);
477 let entry = match remapping {
478 TypeGeneration::Remap(remapped_path) => {
479 let name = format!("__with_name{}", self.with_name_counter);
480 self.with_name_counter += 1;
481 uwriteln!(
482 self.src,
483 "#[allow(unfulfilled_lint_expectations, unused_imports)]"
484 );
485 uwriteln!(self.src, "use {remapped_path} as {name};");
486 InterfaceName {
487 remapped: true,
488 path: name,
489 }
490 }
491 TypeGeneration::Generate => {
492 let path = compute_module_path(name, resolve, is_export).join("::");
493
494 InterfaceName {
495 remapped: false,
496 path,
497 }
498 }
499 };
500
501 let remapped = entry.remapped;
502 let prev = self.interface_names.insert(id, entry);
503 assert!(prev.is_none());
504
505 Ok(remapped)
506 }
507
508 fn finish_runtime_module(&mut self) {
509 if !self.rt_module.is_empty() {

Callers 1

preprocessMethod · 0.80

Calls 4

compute_module_pathFunction · 0.85
joinMethod · 0.80
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected