mirror of
https://github.com/napi-rs/napi-rs.git
synced 2025-12-08 19:56:07 +00:00
feat(napi): impl io::Read for Uint8Array (#2336)
This commit is contained in:
parent
ac30f591dd
commit
00a3c13b42
@ -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<usize> {
|
||||
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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user