Skip to main content

oak_wit_component/ast/
mod.rs

1#![doc = include_str!("readme.md")]
2/// WIT root node
3#[derive(Clone, Debug)]
4pub struct WitRoot {
5    pub items: Vec<WitItem>,
6}
7
8/// WIT item
9#[derive(Clone, Debug)]
10pub enum WitItem {
11    Package(WitPackage),
12    World(WitWorld),
13    Interface(WitInterface),
14}
15
16/// WIT package
17#[derive(Clone, Debug)]
18pub struct WitPackage {
19    pub name: String,
20}
21
22/// WIT world
23#[derive(Clone, Debug)]
24pub struct WitWorld {
25    pub name: String,
26    pub items: Vec<WitWorldItem>,
27}
28
29/// WIT world item
30#[derive(Clone, Debug)]
31pub enum WitWorldItem {
32    Import(WitImport),
33    Export(WitExport),
34    Include(WitInclude),
35}
36
37/// WIT interface
38#[derive(Clone, Debug)]
39pub struct WitInterface {
40    pub name: String,
41    pub items: Vec<WitInterfaceItem>,
42}
43
44/// WIT interface item
45#[derive(Clone, Debug)]
46pub enum WitInterfaceItem {
47    Type(WitType),
48    Func(WitFunc),
49}
50
51/// WIT function
52#[derive(Clone, Debug)]
53pub struct WitFunc {
54    pub name: String,
55    pub params: Vec<WitParam>,
56    pub result: Option<WitTypeKind>,
57}
58
59/// WIT parameter
60#[derive(Clone, Debug)]
61pub struct WitParam {
62    pub name: String,
63    pub ty: WitTypeKind,
64}
65
66/// WIT type
67#[derive(Clone, Debug)]
68pub struct WitType {
69    pub name: String,
70    pub kind: WitTypeKind,
71}
72
73/// WIT type kind
74#[derive(Clone, Debug)]
75pub enum WitTypeKind {
76    Bool,
77    U32,
78    String,
79    // ...
80}
81
82/// WIT import
83#[derive(Clone, Debug)]
84pub struct WitImport {
85    pub name: String,
86}
87
88/// WIT export
89#[derive(Clone, Debug)]
90pub struct WitExport {
91    pub name: String,
92}
93
94/// WIT include
95#[derive(Clone, Debug)]
96pub struct WitInclude {
97    pub name: String,
98}