napi_h/
async_cleanup_hook.rs1use std::mem;
2
3use crate::{sys, Status};
4
5#[repr(transparent)]
9pub struct AsyncCleanupHook(pub(crate) sys::napi_async_cleanup_hook_handle);
10
11impl AsyncCleanupHook {
12 pub fn forget(self) {
15 mem::forget(self);
16 }
17}
18
19impl Drop for AsyncCleanupHook {
20 fn drop(&mut self) {
21 let status = unsafe { sys::napi_remove_async_cleanup_hook(self.0) };
22 assert!(
23 status == sys::Status::napi_ok,
24 "Delete async cleanup hook failed: {}",
25 Status::from(status)
26 );
27 }
28}