use crate::rc::Rc;
use crate::{v8_value_create_array_buffer_with_copy, ImplV8BackingStore, V8BackingStore, V8Value};
pub fn v8_value_create_array_buffer_from_bytes(bytes: &[u8]) -> Option<V8Value> {
v8_value_create_array_buffer_with_copy(bytes.as_ptr().cast_mut(), bytes.len())
}
impl V8BackingStore {
pub fn write(&mut self, bytes: &[u8]) -> bool {
if !self.has_one_ref() || self.byte_length() != bytes.len() {
return false;
}
let data = self.data().cast::<u8>();
if data.is_null() {
return false;
}
unsafe { std::ptr::copy_nonoverlapping(bytes.as_ptr(), data, bytes.len()) };
true
}
}