@@ -12,7 +12,7 @@ use wizer::Wizer;
1212static RUBY_WASM : value:: Lazy < RModule > =
1313 value:: Lazy :: new ( |ruby| ruby. define_module ( "RubyWasmExt" ) . unwrap ( ) ) ;
1414
15- fn preinit ( core_module : Vec < u8 > ) -> Result < Vec < u8 > , Error > {
15+ fn preinit ( core_module : bytes :: Bytes ) -> Result < bytes :: Bytes , Error > {
1616 let rbwasm_error = eval ( "RubyWasmExt::Error" ) ?;
1717 let rbwasm_error = ExceptionClass :: from_value ( rbwasm_error) . unwrap ( ) ;
1818 let mut wizer = Wizer :: new ( ) ;
@@ -26,6 +26,7 @@ fn preinit(core_module: Vec<u8>) -> Result<Vec<u8>, Error> {
2626 wizer
2727 . run ( & core_module)
2828 . map_err ( |e| Error :: new ( rbwasm_error, format ! ( "failed to run wizer: {}" , e) ) )
29+ . map ( |output| output. into ( ) )
2930}
3031
3132struct WasiVfsInner {
@@ -53,14 +54,14 @@ impl WasiVfs {
5354 self . 0 . borrow_mut ( ) . map_dirs . push ( ( guest_dir. into ( ) , host_dir. into ( ) ) ) ;
5455 }
5556
56- fn pack ( & self , wasm_bytes : Vec < u8 > ) -> Result < Vec < u8 > , Error > {
57+ fn pack ( & self , wasm_bytes : bytes :: Bytes ) -> Result < bytes :: Bytes , Error > {
5758 let output_bytes = wasi_vfs_cli:: pack ( & wasm_bytes, self . 0 . borrow ( ) . map_dirs . clone ( ) ) . map_err ( |e| {
5859 Error :: new (
5960 exception:: standard_error ( ) ,
6061 format ! ( "failed to pack wasi vfs: {}" , e) ,
6162 )
6263 } ) ?;
63- Ok ( output_bytes)
64+ Ok ( output_bytes. into ( ) )
6465 }
6566}
6667
@@ -83,7 +84,7 @@ impl ComponentLink {
8384 Ok ( ( ) )
8485 }
8586
86- fn library ( & self , name : String , module : Vec < u8 > , dl_openable : bool ) -> Result < ( ) , Error > {
87+ fn library ( & self , name : String , module : bytes :: Bytes , dl_openable : bool ) -> Result < ( ) , Error > {
8788 self . linker ( |linker| {
8889 linker. library ( & name, & module, dl_openable) . map_err ( |e| {
8990 Error :: new (
@@ -93,7 +94,7 @@ impl ComponentLink {
9394 } )
9495 } )
9596 }
96- fn adapter ( & self , name : String , module : Vec < u8 > ) -> Result < ( ) , Error > {
97+ fn adapter ( & self , name : String , module : bytes :: Bytes ) -> Result < ( ) , Error > {
9798 self . linker ( |linker| {
9899 linker. adapter ( & name, & module) . map_err ( |e| {
99100 Error :: new (
@@ -123,7 +124,7 @@ impl ComponentLink {
123124 Ok ( linker. use_built_in_libdl ( use_libdl) )
124125 } )
125126 }
126- fn encode ( & self ) -> Result < Vec < u8 > , Error > {
127+ fn encode ( & self ) -> Result < bytes :: Bytes , Error > {
127128 // Take the linker out of the cell and consume it
128129 let linker = self . 0 . borrow_mut ( ) . take ( ) . ok_or_else ( || {
129130 Error :: new (
@@ -137,7 +138,7 @@ impl ComponentLink {
137138 format ! ( "failed to encode linker: {}" , e) ,
138139 )
139140 } ) ?;
140- Ok ( encoded)
141+ Ok ( encoded. into ( ) )
141142 }
142143}
143144
0 commit comments