# afia-component-sys
> A low-level Rust wrapper for `libafia_component`.
## Overview
`libafia_component` is a static library that provides a C interface for implementing and testing Afia site components.
It can be downloaded from https://afiaproject.com .
The `afia-component-sys` crate wraps `libafia_component` in a low-level Rust interface.
For example, this crate exposes `libafia_component`'s `create_element` function like so:
```rust
// Links to `libafia_component` and re-exports its `create_element` function
// as a Rust function.
#[link(name = "afia_component")]
extern "C" {
pub fn create_element(
host_handle: *const std::ffi::c_void,
tag_name_ptr: *const u8,
tag_name_len: usize,
) -> i64;
}
```
## Adding Bindings
As a starting point, we are adding bindings by hand. Bindings are written in `src/lib.rs`.
In the future, Afia distributions will include header files and JSON files that describe the `libafia_component`
interface.
After that we can explore automatically generating `afia-component-sys`'s bindings.
In the future, after Afia we can explore automatically generating these bindings.
## To Test
```sh
cargo test -p afia-component-sys
```
## Optional Features
- **`emulate-imports`** - Instead of importing functionality from the Afia host, expose an `EmulatedImports`
that can be used to emulate the Afia host. Useful when testing a component.
- **`test-utils`** - Exposes types that are useful for testing.