Develop a single module service
In this section, we'll fly through the process of the creation of a simple greeting service.
For a backend module and a service to be compatible with the Marine runtime and able to link with other modules, they must follow a few conventions. With the Marine Rust SDK, these conventions will be enforced automatically.
Create a Marine project
Let's start with the template project generation:
sh
sh
This template project reflects the greeting service that we want to build, let's open src/main.rs and see what it's like to write a simple project with Marine:
rust
rust
This code imports the Marine SDK and wraps the greeting function with the #[marine] macro. Any function wrapped with the #[marine] macro will be exported from the compiled Wasm module.
Compile to Wasm
To convert the module to a Wasm (.wasm) file, run the following command in the greeting directory:
sh
sh
To make sure that module compiled correctly, let's retrieve some internal info from it:
sh
sh
That's it, you have a module ready to run!
Run greeting with REPL
To load a module, you need to specify the module name and path to the compiled binary of the module
sh
sh
After loading the module, we can examine its interface using the interface command:
sh
sh
Now the function determined in the module can be called by specifying the module name, the function name, and its arguments in json:
sh
sh
The complete code of this example can be found on GitHub.