From f8927bd16a5fa996d23eebfed8762c1b0dc0244c Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Fri, 22 Sep 2023 21:17:30 +0100 Subject: rust/rusty: Add wrappers for new functions libunit-wasm added two new functions, luw_req_buf_copy() & luw_mem_splice_file(). See the previous two commits... This second function takes a file-descriptor as one of its arguments, in rusty we make this a Rust File object, then pass the underlying fd into libunit-wasm. Signed-off-by: Andrew Clayton --- src/rust/unit-wasm-sys/rusty.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rust/unit-wasm-sys/rusty.rs b/src/rust/unit-wasm-sys/rusty.rs index bf9cd64..8132ef0 100644 --- a/src/rust/unit-wasm-sys/rusty.rs +++ b/src/rust/unit-wasm-sys/rusty.rs @@ -8,6 +8,8 @@ use std::ffi::c_char; use std::ffi::c_void; use std::ffi::CStr; +use std::fs::File; +use std::os::fd::{AsRawFd, RawFd}; use std::ptr::null_mut; use std::slice; use std::str; @@ -175,6 +177,17 @@ pub fn uwr_req_buf_append(ctx: *mut luw_ctx_t, src: *const u8) { } } +pub fn uwr_req_buf_copy(ctx: *mut luw_ctx_t, src: *const u8) { + unsafe { + luw_req_buf_copy(ctx, src); + } +} + +pub fn uwr_mem_splice_file(src: *const u8, f: &mut File) -> isize { + let fd: RawFd = f.as_raw_fd(); + unsafe { luw_mem_splice_file(src, fd) } +} + pub fn uwr_mem_fill_buf_from_req(ctx: *mut luw_ctx_t, from: usize) -> usize { unsafe { luw_mem_fill_buf_from_req(ctx, from) } } -- cgit