File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use crate::scope::PinScope;
88use crate :: support:: int;
99use std:: convert:: TryInto ;
1010use std:: ffi:: c_void;
11+ use std:: mem:: MaybeUninit ;
1112
1213unsafe extern "C" {
1314 fn v8__ArrayBufferView__Buffer (
@@ -93,6 +94,21 @@ impl ArrayBufferView {
9394 }
9495 }
9596
97+ /// Copy the contents of the ArrayBufferView's buffer to an embedder defined
98+ /// memory without additional overhead that calling ArrayBufferView::Buffer
99+ /// might incur.
100+ /// Returns the number of bytes actually written.
101+ #[ inline( always) ]
102+ pub fn copy_contents_uninit ( & self , dest : & mut [ MaybeUninit < u8 > ] ) -> usize {
103+ unsafe {
104+ v8__ArrayBufferView__CopyContents (
105+ self ,
106+ dest. as_mut_ptr ( ) as * mut c_void ,
107+ dest. len ( ) . try_into ( ) . unwrap ( ) ,
108+ )
109+ }
110+ }
111+
96112 /// Returns the contents of the ArrayBufferView's buffer as a MemorySpan. If
97113 /// the contents are on the V8 heap, they get copied into `storage`. Otherwise
98114 /// a view into the off-heap backing store is returned. The provided storage
You can’t perform that action at this time.
0 commit comments