From f6253288684b262e2c913b10a5a8396062f532fe Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 26 Jan 2024 14:32:11 +0800 Subject: [PATCH] fix(napi): move JsValuesTupleIntoVec trait to function.rs --- crates/napi/src/bindgen_runtime/js_values/function.rs | 9 +++++---- crates/napi/src/threadsafe_function.rs | 8 +++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/napi/src/bindgen_runtime/js_values/function.rs b/crates/napi/src/bindgen_runtime/js_values/function.rs index 1805c4e0..53f572c0 100644 --- a/crates/napi/src/bindgen_runtime/js_values/function.rs +++ b/crates/napi/src/bindgen_runtime/js_values/function.rs @@ -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>; +} + /// 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. diff --git a/crates/napi/src/threadsafe_function.rs b/crates/napi/src/threadsafe_function.rs index 56085177..45504079 100644 --- a/crates/napi/src/threadsafe_function.rs +++ b/crates/napi/src/threadsafe_function.rs @@ -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 Clone for ThreadsafeFunction { } } -pub trait JsValuesTupleIntoVec { - fn into_vec(self, env: sys::napi_env) -> Result>; -} - impl JsValuesTupleIntoVec for T { #[allow(clippy::not_unsafe_ptr_arg_deref)] fn into_vec(self, env: sys::napi_env) -> Result> {