afia-component-sys 0.0.4

A low-level Rust wrapper for `libafia_component`.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 28.51 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 533.06 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 24s Average build duration of successful builds.
  • all releases: 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chinedufn

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:

// 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

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.