File tree Expand file tree Collapse file tree
examples/tutorial/adder/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #[ allow( warnings) ]
2- mod bindings;
1+ mod bindings {
2+ //! This module contains generated code for implementing
3+ //! the `adder` world in `wit/world.wit`.
4+ //!
5+ //! The `path` option is actually not required,
6+ //! as by default `wit_bindgen::generate` will look
7+ //! for a top-level `wit` directory and use the files
8+ //! (and interfaces/worlds) there-in.
9+ wit_bindgen:: generate!( {
10+ path: "wit/world.wit" ,
11+ } ) ;
312
4- // The comments that follow the `use` declaration below
5- // correlate the rust module path segments with their
6- // `world.wit` counterparts:
7- use bindings:: exports:: docs:: adder:: add:: Guest ;
8- // <- items bundled with `export` keyword
9- // <- package namespace
10- // <- package
11- // <- interface name
13+ use super :: AdderComponent ;
14+ export ! ( AdderComponent ) ;
15+ }
1216
13- struct Component ;
17+ /// Struct off of which the implementation will hang
18+ ///
19+ /// The name of this struct is not significant.
20+ #[ allow( dead_code) ]
21+ struct AdderComponent ;
1422
15- impl Guest for Component {
23+ impl bindings :: exports :: docs :: adder :: add :: Guest for AdderComponent {
1624 fn add ( x : u32 , y : u32 ) -> u32 {
1725 x + y
1826 }
1927}
20-
21- bindings:: export!( Component with_types_in bindings) ;
Original file line number Diff line number Diff line change @@ -141,33 +141,7 @@ We can fill in functionality of the component by implementing `bindings::Guest`
141141Your code should look something like the following:
142142
143143``` rs
144- mod bindings {
145- // ! This module contains generated code for implementing
146- // ! the `adder` world in `wit/world.wit`.
147- // !
148- // ! The `path` option is actually not required,
149- // ! as by default `wit_bindgen::generate` will look
150- // ! for a top-level `wit` directory and use the files
151- // ! (and interfaces/worlds) there-in.
152- wit_bindgen :: generate! ({
153- path : " wit/world.wit" ,
154- });
155-
156- use super :: AdderComponent ;
157- export! (AdderComponent );
158- }
159-
160- /// Struct off of which the implementation will hang
161- ///
162- /// The name of this struct is not significant.
163- #[allow(dead_code)]
164- struct AdderComponent ;
165-
166- impl bindings :: exports :: docs :: adder :: add :: Guest for AdderComponent {
167- fn add (x : u32 , y : u32 ) -> u32 {
168- x + y
169- }
170- }
144+ {{#include .. / .. / examples / tutorial / adder / src / lib . rs}}
171145```
172146
173147There are a few points of note in the code listing above:
You can’t perform that action at this time.
0 commit comments