feat(napi): implement napi_reference_ref

This commit is contained in:
LongYinan 2020-10-10 18:21:11 +08:00
parent e0d75d1453
commit 3da8daf192
No known key found for this signature in database
GPG key ID: A3FFE134A3E20881

View file

@ -32,6 +32,11 @@ impl<T> Ref<T> {
})
}
pub fn reference(&mut self, env: &Env) -> Result<u32> {
check_status(unsafe { sys::napi_reference_ref(env.0, self.raw_ref, &mut self.count) })?;
Ok(self.count)
}
#[must_use]
pub fn unref(mut self, env: Env) -> Result<u32> {
check_status(unsafe { sys::napi_reference_unref(env.0, self.raw_ref, &mut self.count) })?;