---
# System prepended metadata

title: Rust Native API

---

# Rust Native API

## Desired Developer Experience

```cpp
WasmWrapper wrapper = {
    .file_reader = create_simple_file_reader(),
    .manifest = get_manifest()
};

wrapper.wasm_module = get_wasm_module(&wrapper);

const char* builder_ptr = create_resolver_builder();
add_static_resolver(&builder_ptr, static_resolver);
add_static_resolver(&builder_ptr, another_static_resolver);
const char* client = create_client(builder_ptr);
```

## Patterns

### Instantiate `Wrappers` in the application language

**Library side (Rust):**
```rust
pub struct SimpleFileReader {
    ...
}

#[repr(C)]
pub struct WasmWrapper {
    wasm_module: Vec<u8>,
    file_reader: SimpleFileReader,
    manifest: WrapManifest,
}

impl WasmWrapper {
    ...
}
```

**App side (C++):**
```cpp
struct SimpleFileReader {
    // fields of SimpleFileReader
    ...
} ;

struct WrapManifest {
    // fields of WrapManifest
    ...
};

struct WasmWrapper {
    // fields of WasmWrapper
    uint8_t* wasm_module;
    SimpleFileReader file_reader;
    WrapManifest manifest;
};
```



# Needs

- Msgpack to handle invocation result
- Way for users to insert plugins (?)
- 