diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2023-09-22 21:17:30 +0100 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2023-09-25 17:39:51 +0100 |
commit | f8927bd16a5fa996d23eebfed8762c1b0dc0244c (patch) | |
tree | a7fe80087b3f08aea096bc87e3c240d27c6d6ab3 /src/rust/unit-wasm-sys/rusty.rs | |
parent | 43c8e44d33572b818cdd0a5945e494c5510ab24f (diff) | |
download | unit-wasm-f8927bd16a5fa996d23eebfed8762c1b0dc0244c.tar.gz unit-wasm-f8927bd16a5fa996d23eebfed8762c1b0dc0244c.tar.bz2 |
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 <a.clayton@nginx.com>
Diffstat (limited to '')
-rw-r--r-- | src/rust/unit-wasm-sys/rusty.rs | 13 |
1 files changed, 13 insertions, 0 deletions
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) } } |