MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / generate_interface_name

Method generate_interface_name

crates/wit-bindgen/src/lib.rs:258–284  ·  view source on GitHub ↗
(
        &mut self,
        resolve: &Resolve,
        id: InterfaceId,
        name: &WorldKey,
        interface_kind: InterfaceKind,
    )

Source from the content-addressed store, hash-verified

256 }
257
258 fn generate_interface_name(
259 &mut self,
260 resolve: &Resolve,
261 id: InterfaceId,
262 name: &WorldKey,
263 interface_kind: InterfaceKind,
264 ) -> Vec<String> {
265 let mut path = Vec::new();
266 match interface_kind {
267 InterfaceKind::Import => {}
268 InterfaceKind::Export => path.push("exports".to_string()),
269 InterfaceKind::Named => path.push("named_imports".to_string()),
270 }
271 match name {
272 WorldKey::Name(name) => {
273 path.push(name.to_snake_case());
274 }
275 WorldKey::Interface(_) => {
276 let iface = &resolve.interfaces[id];
277 let pkgname = &resolve.packages[iface.package.unwrap()].name;
278 path.push(pkgname.namespace.to_snake_case());
279 path.push(self.name_package_module(resolve, iface.package.unwrap()));
280 path.push(to_rust_ident(iface.name.as_ref().unwrap()));
281 }
282 }
283 path
284 }
285
286 fn name_interface(
287 &mut self,

Callers 2

name_interfaceMethod · 0.80
generate_named_importMethod · 0.80

Calls 7

to_rust_identFunction · 0.85
name_package_moduleMethod · 0.80
newFunction · 0.50
pushMethod · 0.45
to_stringMethod · 0.45
unwrapMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected