diff --git a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs index 02d3cc77..363f643a 100644 --- a/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs +++ b/crates/napi/src/bindgen_runtime/js_values/arraybuffer.rs @@ -1,4 +1,5 @@ use std::ffi::c_void; +use std::io::{self, Read}; use std::mem; use std::ops::{Deref, DerefMut}; use std::ptr; @@ -679,6 +680,13 @@ impl Uint8Array { } } +impl Read for Uint8Array { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + let mut inner: &[u8] = &*self; + Read::read(&mut inner, buf) + } +} + /// Zero copy Uint8ClampedArray slice shared between Rust and Node.js. /// It can only be used in non-async context and the lifetime is bound to the fn closure. /// If you want to use Node.js `Uint8ClampedArray` in async context or want to extend the lifetime, use `Uint8ClampedArray` instead.