Export functions
Applying the #[marine] macro to a function results in its export, which means that it can be called from other modules or AIR scripts.
mtype
For the function to be compatible with this macro, its arguments must be of the mtype, which is defined as follows:
mtype = bool, u8, u16, u32, u64, i8, i16, i32, i64, f32, f64, String
mtype = mtype | Vec<mtype>
mtype = mtype | Record<mtype>
Function Export Requirements
In other words, the arguments must be one of the types listed below:
- one of the following Rust basic types: bool,u8,u16,u32,u64,i8,i16,i32,i64,f32,f64,String
- a vector of elements of the above types
- a vector composed of vectors of the above type, where recursion is acceptable, e.g. the type Vec<Vec<Vec<u8>>>is permissible
- a record, where all fields are of the basic Rust types
- a record, where all fields are of any above types or other records
The return type of a function must follow the same rules, but currently, only one return type is possible.
Examples
See the example below of an exposed function with a complex type signature and return value:
- Example 1
- Example 2
rust
rust
rust
rust