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

Method ty

crates/wit-bindgen/src/rust.rs:34–67  ·  view source on GitHub ↗
(&self, ty: &Type, mode: TypeMode)

Source from the content-addressed store, hash-verified

32 self.push_str(&self.ty(ty, mode))
33 }
34 fn ty(&self, ty: &Type, mode: TypeMode) -> String {
35 match ty {
36 Type::Id(t) => self.tyid(*t, mode),
37 Type::Bool => "bool".to_string(),
38 Type::U8 => "u8".to_string(),
39 Type::U16 => "u16".to_string(),
40 Type::U32 => "u32".to_string(),
41 Type::U64 => "u64".to_string(),
42 Type::S8 => "i8".to_string(),
43 Type::S16 => "i16".to_string(),
44 Type::S32 => "i32".to_string(),
45 Type::S64 => "i64".to_string(),
46 Type::F32 => "f32".to_string(),
47 Type::F64 => "f64".to_string(),
48 Type::Char => "char".to_string(),
49 Type::String => match mode {
50 TypeMode::AllBorrowed(lt) => {
51 if lt != "'_" {
52 format!("&{lt} str")
53 } else {
54 format!("&str")
55 }
56 }
57 TypeMode::Owned => {
58 let wt = self.wasmtime_path();
59 format!("{wt}::component::__internal::String")
60 }
61 },
62 Type::ErrorContext => {
63 let wt = self.wasmtime_path();
64 format!("{wt}::component::ErrorContext")
65 }
66 }
67 }
68
69 fn print_optional_ty(&mut self, ty: Option<&Type>, mode: TypeMode) {
70 self.push_str(&self.optional_ty(ty, mode))

Callers 9

print_tyMethod · 0.45
optional_tyMethod · 0.45
tyidMethod · 0.45
listMethod · 0.45
typedfunc_sigMethod · 0.45
type_mapMethod · 0.45

Implementers 1

lib.rscrates/wit-bindgen/src/lib.rs

Calls 3

tyidMethod · 0.80
wasmtime_pathMethod · 0.80
to_stringMethod · 0.45

Tested by 1