File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ pub(crate) fn get_wasi_state(ctx: &Ctx) -> &mut WasiState {
34
34
unsafe { state:: get_wasi_state ( & mut * ( ctx as * const Ctx as * mut Ctx ) ) }
35
35
}
36
36
37
- fn write_bytes < T : Write > (
37
+ fn write_bytes_inner < T : Write > (
38
38
mut write_loc : T ,
39
39
memory : & Memory ,
40
40
iovs_arr_cell : & [ Cell < __wasi_ciovec_t > ] ,
@@ -44,19 +44,25 @@ fn write_bytes<T: Write>(
44
44
let iov_inner = iov. get ( ) ;
45
45
let bytes = iov_inner. buf . deref ( memory, 0 , iov_inner. buf_len ) ?;
46
46
write_loc
47
- . write ( & bytes. iter ( ) . map ( |b_cell| b_cell. get ( ) ) . collect :: < Vec < u8 > > ( ) )
48
- . map_err ( |_| {
49
- write_loc. flush ( ) ;
50
- __WASI_EIO
51
- } ) ?;
47
+ . write_all ( & bytes. iter ( ) . map ( |b_cell| b_cell. get ( ) ) . collect :: < Vec < u8 > > ( ) )
48
+ . map_err ( |_| __WASI_EIO) ?;
52
49
53
50
// TODO: handle failure more accurately
54
51
bytes_written += iov_inner. buf_len ;
55
52
}
56
- write_loc. flush ( ) ;
57
53
Ok ( bytes_written)
58
54
}
59
55
56
+ fn write_bytes < T : Write > (
57
+ mut write_loc : T ,
58
+ memory : & Memory ,
59
+ iovs_arr_cell : & [ Cell < __wasi_ciovec_t > ] ,
60
+ ) -> Result < u32 , __wasi_errno_t > {
61
+ let result = write_bytes_inner ( & mut write_loc, memory, iovs_arr_cell) ;
62
+ write_loc. flush ( ) ;
63
+ result
64
+ }
65
+
60
66
fn read_bytes < T : Read > (
61
67
mut reader : T ,
62
68
memory : & Memory ,
You can’t perform that action at this time.
0 commit comments