feat: edition 2021
This commit is contained in:
parent
b2e71b5e03
commit
e452c00fb4
16 changed files with 62 additions and 36 deletions
crates/napi
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
authors = ["Nathan Sobo <nathan@github.com>", "Yinan Long <lynweklm@gmail.com>"]
|
||||
description = "N-API bindings"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
keywords = ["NodeJS", "Node", "FFI", "NAPI", "n-api"]
|
||||
license = "MIT"
|
||||
name = "napi"
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
js_values::*,
|
||||
sys,
|
||||
task::Task,
|
||||
Error, ExtendedErrorInfo, JsError, NodeVersion, Result, Status, ValueType,
|
||||
Error, ExtendedErrorInfo, NodeVersion, Result, Status, ValueType,
|
||||
};
|
||||
|
||||
#[cfg(feature = "napi8")]
|
||||
|
@ -22,6 +22,8 @@ use crate::cleanup_env::{CleanupEnvHook, CleanupEnvHookData};
|
|||
use crate::js_values::{De, Ser};
|
||||
#[cfg(feature = "napi4")]
|
||||
use crate::threadsafe_function::{ThreadSafeCallContext, ThreadsafeFunction};
|
||||
#[cfg(feature = "napi3")]
|
||||
use crate::JsError;
|
||||
#[cfg(all(feature = "serde-json"))]
|
||||
use serde::de::DeserializeOwned;
|
||||
#[cfg(all(feature = "serde-json"))]
|
||||
|
|
|
@ -25,6 +25,7 @@ pub struct Error {
|
|||
pub reason: String,
|
||||
// Convert raw `JsError` into Error
|
||||
// Only be used in `async fn(p: Promise<T>)` scenario
|
||||
#[cfg(all(feature = "tokio_rt", feature = "napi4"))]
|
||||
pub(crate) maybe_raw: sys::napi_ref,
|
||||
}
|
||||
|
||||
|
@ -54,6 +55,7 @@ impl From<SerdeJSONError> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "tokio_rt", feature = "napi4"))]
|
||||
impl From<sys::napi_ref> for Error {
|
||||
fn from(value: sys::napi_ref) -> Self {
|
||||
Self {
|
||||
|
@ -79,6 +81,7 @@ impl Error {
|
|||
Error {
|
||||
status,
|
||||
reason,
|
||||
#[cfg(all(feature = "tokio_rt", feature = "napi4"))]
|
||||
maybe_raw: ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +90,7 @@ impl Error {
|
|||
Error {
|
||||
status,
|
||||
reason: "".to_owned(),
|
||||
#[cfg(all(feature = "tokio_rt", feature = "napi4"))]
|
||||
maybe_raw: ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +99,7 @@ impl Error {
|
|||
Error {
|
||||
status: Status::GenericFailure,
|
||||
reason,
|
||||
#[cfg(all(feature = "tokio_rt", feature = "napi4"))]
|
||||
maybe_raw: ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +110,7 @@ impl From<std::ffi::NulError> for Error {
|
|||
Error {
|
||||
status: Status::GenericFailure,
|
||||
reason: format!("{}", error),
|
||||
#[cfg(all(feature = "tokio_rt", feature = "napi4"))]
|
||||
maybe_raw: ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +121,7 @@ impl From<std::io::Error> for Error {
|
|||
Error {
|
||||
status: Status::GenericFailure,
|
||||
reason: format!("{}", error),
|
||||
#[cfg(all(feature = "tokio_rt", feature = "napi4"))]
|
||||
maybe_raw: ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue