More cleanup during review
This commit is contained in:
parent
5ec828a3e2
commit
14bccb4a90
9 changed files with 16 additions and 122 deletions
|
@ -39,10 +39,19 @@ Here's an example Rust Wasm plugin that doubles the value of every float in a `V
|
|||
```rust
|
||||
use plugin::prelude::*;
|
||||
|
||||
#[bind]
|
||||
#[export]
|
||||
pub fn double(mut x: Vec<f64>) -> Vec<f64> {
|
||||
x.into_iter().map(|x| x * 2.0).collect()
|
||||
}
|
||||
```
|
||||
|
||||
All the serialization code is automatically generated by `#[bind]`.
|
||||
All the serialization code is automatically generated by `#[export]`.
|
||||
|
||||
You can specify functions that must be defined host-side by using the `#[import]` attribute. This attribute must be attached to a function signature:
|
||||
|
||||
```rust
|
||||
#[import]
|
||||
fn run(command: String) -> Vec<u8>;
|
||||
```
|
||||
|
||||
The `#[import]` macro will generate a function body that performs the proper serialization/deserialization needed to call out to the host rust runtime. Note that the same ABI is used for both `#[import]` and `#[export]`.
|
Loading…
Add table
Add a link
Reference in a new issue