Merge pull request from napi-rs/fix/buffer-vec-conversion

fix(napi): impl From<Buffer> for Vec<u8>
This commit is contained in:
LongYinan 2021-12-18 13:41:40 +08:00 committed by GitHub
commit 3f2e44d3db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 1 deletions
crates/napi/src/bindgen_runtime/js_values

View file

@ -16,6 +16,12 @@ impl From<Vec<u8>> for Buffer {
}
}
impl From<Buffer> for Vec<u8> {
fn from(buf: Buffer) -> Self {
buf.inner.to_vec()
}
}
impl From<&[u8]> for Buffer {
fn from(inner: &[u8]) -> Self {
Buffer::from(inner.to_owned())