fix(napi): move JsValuesTupleIntoVec trait to function.rs

This commit is contained in:
LongYinan 2024-01-26 14:32:11 +08:00
parent f69771e2d4
commit f625328868
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7
2 changed files with 8 additions and 9 deletions

View file

@ -3,13 +3,14 @@ use std::ptr;
use super::{FromNapiValue, ToNapiValue, TypeName, ValidateNapiValue};
pub use crate::JsFunction;
use crate::{
check_pending_exception, check_status, sys, threadsafe_function::JsValuesTupleIntoVec, Env,
NapiRaw, Result, ValueType,
};
use crate::{check_pending_exception, check_status, sys, Env, NapiRaw, Result, ValueType};
impl ValidateNapiValue for JsFunction {}
pub trait JsValuesTupleIntoVec {
fn into_vec(self, env: sys::napi_env) -> Result<Vec<sys::napi_value>>;
}
/// A JavaScript function.
/// It can only live in the scope of a function call.
/// If you want to use it outside the scope of a function call, you can turn it into a reference.

View file

@ -8,7 +8,9 @@ use std::ptr::{self, null_mut};
use std::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
use std::sync::{Arc, RwLock, RwLockWriteGuard, Weak};
use crate::bindgen_runtime::{FromNapiValue, ToNapiValue, TypeName, ValidateNapiValue};
use crate::bindgen_runtime::{
FromNapiValue, JsValuesTupleIntoVec, ToNapiValue, TypeName, ValidateNapiValue,
};
use crate::{check_status, sys, Env, JsError, JsUnknown, Result, Status};
/// ThreadSafeFunction Context object
@ -254,10 +256,6 @@ impl<T: 'static, ES: ErrorStrategy::T> Clone for ThreadsafeFunction<T, ES> {
}
}
pub trait JsValuesTupleIntoVec {
fn into_vec(self, env: sys::napi_env) -> Result<Vec<sys::napi_value>>;
}
impl<T: ToNapiValue> JsValuesTupleIntoVec for T {
#[allow(clippy::not_unsafe_ptr_arg_deref)]
fn into_vec(self, env: sys::napi_env) -> Result<Vec<sys::napi_value>> {