From 1e4aa3a2a54bc5cb30b43836fdeb446a04372973 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 22 Feb 2020 12:34:04 +0800 Subject: [PATCH] feat(buffer): implement from_value --- napi/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/napi/src/lib.rs b/napi/src/lib.rs index 91a06a3a..baa02ddb 100644 --- a/napi/src/lib.rs +++ b/napi/src/lib.rs @@ -602,6 +602,17 @@ impl ValueType for Buffer { } } +impl<'env> Value<'env, Buffer> { + #[inline] + pub fn from_value(env: &'env Env, value: &Value<'env, Any>) -> Value<'env, Buffer> { + Value { + env, + raw_value: value.raw_value, + value: Buffer::from_raw(env.0, value.into_raw()), + } + } +} + impl ValueType for Function { fn from_raw(_env: sys::napi_env, _raw: sys::napi_value) -> Self { Function {}