# afia-component
> A high-level Rust wrapper for `libafia_component`.
## Overview
This crate provides a higher-level safe API on top of the [`afia-component-sys`](../afia-component-sys)
crate.
For instance, creating a new DOM element using the `afia-component` crate looks like:
```rust,no_run
use afia_component::ComponentImports;
let imports = ComponentImports::new_dynamically_linked();
let div = imports.create_element("div").unwrap();
```
Whereas creating a new DOM element using `afia-component-sys` requires direct usage of
pointers and unsafe code:
```rust,no_run
use afia_component_sys::create_element;
let tag = "div";
let div = unsafe { create_element(std::ptr::null(), tag.as_ptr(), tag.len()) };
```
Most developers should choose `afia-component` since it is easier and safer to use
than the raw `afia-component-sys` bindings.
A developer might choose to instead use `afia-component-sys` if they are unsatisfied
with the API that `afia-component` exposes and would prefer to write their own `Rust`
wrapper.
## To Test
First, download a `libafia_component` from https://afiaproject.com .
Then run the tests.
```sh
cargo test -p afia-component
```
## Optional Features
- **`emulate-imports`** - Instead of importing functionality from the Afia host, expose an `EmulatedImports`
that can be used to emulate the Afia host.
- **`test-utils`** - Exposes types that are useful for testing.
- **`macros`** - Expose macros such as `#[create_instance]` and `#[output(..)]`.