pub trait ValidateNapiValue: FromNapiValue + TypeName {
// Provided method
unsafe fn validate(
env: napi_env,
napi_val: napi_value,
) -> Result<napi_value> { ... }
}
Provided Methods§
Sourceunsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
§Safety
this function called to validate whether napi value passed to rust is valid type
The reason why this function return napi_value
is that if a Promise<T>
passed in
we need to return Promise.reject(T)
, not the T
.
So we need to create Promise.reject(T)
in this function.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.