Skip to content

Commit f8927bd

Browse files
committed
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 <[email protected]>
1 parent 43c8e44 commit f8927bd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/rust/unit-wasm-sys/rusty.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use std::ffi::c_char;
99
use std::ffi::c_void;
1010
use std::ffi::CStr;
11+
use std::fs::File;
12+
use std::os::fd::{AsRawFd, RawFd};
1113
use std::ptr::null_mut;
1214
use std::slice;
1315
use std::str;
@@ -175,6 +177,17 @@ pub fn uwr_req_buf_append(ctx: *mut luw_ctx_t, src: *const u8) {
175177
}
176178
}
177179

180+
pub fn uwr_req_buf_copy(ctx: *mut luw_ctx_t, src: *const u8) {
181+
unsafe {
182+
luw_req_buf_copy(ctx, src);
183+
}
184+
}
185+
186+
pub fn uwr_mem_splice_file(src: *const u8, f: &mut File) -> isize {
187+
let fd: RawFd = f.as_raw_fd();
188+
unsafe { luw_mem_splice_file(src, fd) }
189+
}
190+
178191
pub fn uwr_mem_fill_buf_from_req(ctx: *mut luw_ctx_t, from: usize) -> usize {
179192
unsafe { luw_mem_fill_buf_from_req(ctx, from) }
180193
}

0 commit comments

Comments
 (0)