1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use super::*;
use alloc::vec::Vec;
pub trait TypeAbi {
fn type_name() -> TypeName {
core::any::type_name::<Self>().into()
}
fn provide_type_descriptions<TDC: TypeDescriptionContainer>(accumulator: &mut TDC) {
let type_name = Self::type_name();
accumulator.insert(
type_name,
TypeDescription {
docs: &[],
name: Self::type_name(),
contents: TypeContents::NotSpecified,
},
);
}
#[doc(hidden)]
fn is_variadic() -> bool {
false
}
#[doc(hidden)]
fn output_abis(output_names: &[&'static str]) -> OutputAbis {
let mut result = Vec::with_capacity(1);
let output_name = if !output_names.is_empty() {
output_names[0]
} else {
""
};
result.push(OutputAbi {
output_name,
type_name: Self::type_name(),
multi_result: Self::is_variadic(),
});
result
}
}
pub fn type_name_variadic<T: TypeAbi>() -> TypeName {
let mut repr = TypeName::from("variadic<");
repr.push_str(T::type_name().as_str());
repr.push('>');
repr
}
pub fn type_name_optional<T: TypeAbi>() -> TypeName {
let mut repr = TypeName::from("optional<");
repr.push_str(T::type_name().as_str());
repr.push('>');
repr
}