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

Method path_to_interface

crates/rust/src/interface.rs:2483–2520  ·  view source on GitHub ↗
(&self, interface: InterfaceId)

Source from the content-addressed store, hash-verified

2481 }
2482
2483 fn path_to_interface(&self, interface: InterfaceId) -> Option<String> {
2484 let Some(InterfaceName { path, remapped }) = &self.r#gen.interface_names.get(&interface)
2485 else {
2486 let name = self.resolve.interfaces[interface].name.as_ref().unwrap();
2487 panic!("Cannot find interface {interface:?}: {name}");
2488 };
2489 if *remapped {
2490 let mut path_to_root = self.path_to_root();
2491 path_to_root.push_str(path);
2492 return Some(path_to_root);
2493 } else {
2494 let mut full_path = String::new();
2495 match self.identifier {
2496 Identifier::Interface(cur, name) => {
2497 if cur == interface {
2498 return None;
2499 }
2500 if !self.in_import {
2501 full_path.push_str("super::");
2502 }
2503 match name {
2504 WorldKey::Name(_) => {
2505 full_path.push_str("super::");
2506 }
2507 WorldKey::Interface(_) => {
2508 full_path.push_str("super::super::super::");
2509 }
2510 }
2511 }
2512 Identifier::StreamOrFuturePayload => {
2513 full_path.push_str("super::super::");
2514 }
2515 _ => {}
2516 }
2517 full_path.push_str(&path);
2518 Some(full_path)
2519 }
2520 }
2521
2522 fn push_vec_name(&mut self) {
2523 let path = self.path_to_vec();

Callers 2

generate_stubMethod · 0.80
type_path_with_nameMethod · 0.80

Calls 4

newFunction · 0.85
path_to_rootMethod · 0.80
getMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected