diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2023-08-24 20:03:25 +0100 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2023-08-25 21:13:49 +0100 |
commit | 55a41414b87301e37d9dc35937694d5aa13d9d99 (patch) | |
tree | bd19eacf97c5b3888ea89f502c6105bd3b5712d3 /README.md | |
parent | 5f8623b45b1ff9c96f0db57fcc41eb5e1bbca90e (diff) | |
download | unit-wasm-55a41414b87301e37d9dc35937694d5aa13d9d99.tar.gz unit-wasm-55a41414b87301e37d9dc35937694d5aa13d9d99.tar.bz2 |
Rust: Add a nicer wrapper around the libunit-wasm bindings
This adds a nice wrapper (aka rusty) around the generated libunit-wasm
bindings.
This should provide a more native rust like experience with the
following benefits
- No casting. So no things like 'as *mut c_void'
- Native rust strings. So no things like '.as_ptr() as *const c_char'
- Better ctx initialisation. Filed initialisation is now hidden away
- Great reduction in the amount of unsafe {} blocks required
- Generally more compact
There are also some new macros
- C2S!() converts a CStr to a Str
- S2C!() converts a formatted Str to a Cstr using format!()
- uwr_write_str!() a wrapper around luw_mem_writep_data and format!()
This wrapper uses a uwr (Unit Wasm Rust) prefix under a 'rusty'
namespace.
The luw_http_hdr_iter() function proved tricky to wrap and the callback
function still takes C style arguments due to the fact that this
function is called from the libunit-wasm C library.
The provided wrapper simply means we can use this without having to use
an unsafe {} block around it in application code.
Similarly with other functions that technically didn't need to be
wrapped, wrapping them means that the unsafe {} blocks are hidden away.
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions