feat(buffer): implement from_value

This commit is contained in:
LongYinan 2020-02-22 12:34:04 +08:00
parent 0bfcdff29f
commit 1e4aa3a2a5
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7

View file

@ -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 {}