buffer example

This commit is contained in:
forehalo 2021-10-08 21:13:27 +08:00 committed by LongYinan
parent aa77c8ff97
commit 8b4e7af67f
7 changed files with 20 additions and 0 deletions
crates/napi/src/bindgen_runtime/js_values

View file

@ -18,6 +18,12 @@ impl From<Vec<u8>> for Buffer {
}
}
impl From<&[u8]> for Buffer {
fn from(inner: &[u8]) -> Self {
Buffer::from(inner.to_owned())
}
}
impl AsRef<[u8]> for Buffer {
fn as_ref(&self) -> &[u8] {
self.inner.as_slice()