Expand description
§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 anEmulatedImportsthat can be used to emulate the Afia host. Useful when testing a component.test-utils- Exposes types that are useful for testing.
Structs§
- Allocated
String - A pointer and length pair for a UTF-8 string.
Functions§
- create_
element ⚠ - create_
stripe_ ⚠elements - create_
text ⚠ - dialog_
element_ ⚠close - dialog_
element_ ⚠show_ modal - dom_
element_ ⚠add_ event_ listener - dom_
element_ ⚠append_ child - dom_
element_ ⚠next_ element_ sibling - dom_
element_ ⚠previous_ element_ sibling - dom_
element_ ⚠remove_ attribute - dom_
element_ ⚠set_ attribute - dom_
element_ ⚠set_ text_ content - dom_
event_ ⚠prevent_ default - dom_
event_ ⚠target - dom_
node_ ⚠get_ property_ bool - dom_
node_ ⚠get_ property_ string - dom_
node_ ⚠set_ property_ bool - dom_
node_ ⚠set_ property_ string - element_
child_ ⚠nodes - element_
click ⚠ - element_
get_ ⚠attribute - element_
inner_ ⚠text - element_
tag_ ⚠name - initialize_
stripe ⚠ - input_
element_ ⚠value - local_
storage_ ⚠get_ item - local_
storage_ ⚠set_ item - node_
list_ ⚠item - node_
type ⚠ - output_
may_ ⚠have_ changed - parent_
node ⚠ - submit_
stripe_ ⚠elements