fix(napi): add UnknownReturnValue to use in call_async scenario (#1451)

This commit is contained in:
LongYinan 2023-01-24 17:41:36 +08:00 committed by GitHub
parent 694f761fd9
commit 54dd120880
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@ use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use crate::bindgen_runtime::{FromNapiValue, ToNapiValue}; use crate::bindgen_runtime::{FromNapiValue, ToNapiValue, TypeName, ValidateNapiValue};
use crate::{check_status, sys, Env, JsError, JsUnknown, Result, Status}; use crate::{check_status, sys, Env, JsError, JsUnknown, Result, Status};
/// ThreadSafeFunction Context object /// ThreadSafeFunction Context object
@ -747,3 +747,23 @@ macro_rules! type_level_enum {(
)} )}
use type_level_enum; use type_level_enum;
pub struct UnknownReturnValue;
impl TypeName for UnknownReturnValue {
fn type_name() -> &'static str {
"UnknownReturnValue"
}
fn value_type() -> crate::ValueType {
crate::ValueType::Unknown
}
}
impl ValidateNapiValue for UnknownReturnValue {}
impl FromNapiValue for UnknownReturnValue {
unsafe fn from_napi_value(_env: sys::napi_env, _napi_val: sys::napi_value) -> Result<Self> {
Ok(UnknownReturnValue)
}
}