pub trait TryFromJs<'cx>where
Self: Sealed + Sized,{
type Error: TryIntoJs<'cx>;
// Required method
fn try_from_js(
cx: &mut Cx<'cx>,
v: Handle<'cx, JsValue>,
) -> NeonResult<Result<Self, Self::Error>>;
// Provided method
fn from_js(cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>) -> NeonResult<Self> { ... }
}
Expand description
Extract Rust data from a JavaScript value
Required Associated Types§
Required Methods§
Sourcefn try_from_js(
cx: &mut Cx<'cx>,
v: Handle<'cx, JsValue>,
) -> NeonResult<Result<Self, Self::Error>>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Extract this Rust type from a JavaScript value
Provided Methods§
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.
Implementations on Foreign Types§
Source§impl<'cx> TryFromJs<'cx> for bool
impl<'cx> TryFromJs<'cx> for bool
type Error = TypeExpected<JsBoolean>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx> TryFromJs<'cx> for f64
impl<'cx> TryFromJs<'cx> for f64
type Error = TypeExpected<JsNumber>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx> TryFromJs<'cx> for ()
impl<'cx> TryFromJs<'cx> for ()
type Error = Infallible
fn try_from_js( _cx: &mut Cx<'cx>, _v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx> TryFromJs<'cx> for String
impl<'cx> TryFromJs<'cx> for String
type Error = TypeExpected<JsString>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx, T> TryFromJs<'cx> for Vec<T>
impl<'cx, T> TryFromJs<'cx> for Vec<T>
type Error = TypeExpected<JsTypedArray<T>>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Implementors§
Source§impl<'cx> TryFromJs<'cx> for Date
Available on crate feature napi-5
only.
impl<'cx> TryFromJs<'cx> for Date
Available on crate feature
napi-5
only.type Error = TypeExpected<JsDate>
Source§impl<'cx, B> TryFromJs<'cx> for ArrayBuffer<B>
impl<'cx, B> TryFromJs<'cx> for ArrayBuffer<B>
type Error = TypeExpected<JsBuffer>
Source§impl<'cx, T> TryFromJs<'cx> for BigInt64Array<T>
impl<'cx, T> TryFromJs<'cx> for BigInt64Array<T>
type Error = TypeExpected<JsTypedArray<i64>>
Source§impl<'cx, T> TryFromJs<'cx> for BigUint64Array<T>
impl<'cx, T> TryFromJs<'cx> for BigUint64Array<T>
type Error = TypeExpected<JsTypedArray<u64>>
Source§impl<'cx, T> TryFromJs<'cx> for Boxed<T>where
T: Clone + 'static,
impl<'cx, T> TryFromJs<'cx> for Boxed<T>where
T: Clone + 'static,
type Error = TypeExpected<JsBox<T>>
Source§impl<'cx, T> TryFromJs<'cx> for Float32Array<T>
impl<'cx, T> TryFromJs<'cx> for Float32Array<T>
type Error = TypeExpected<JsTypedArray<f32>>
Source§impl<'cx, T> TryFromJs<'cx> for Float64Array<T>
impl<'cx, T> TryFromJs<'cx> for Float64Array<T>
type Error = TypeExpected<JsTypedArray<f64>>
Source§impl<'cx, T> TryFromJs<'cx> for Int8Array<T>
impl<'cx, T> TryFromJs<'cx> for Int8Array<T>
type Error = TypeExpected<JsTypedArray<i8>>
Source§impl<'cx, T> TryFromJs<'cx> for Int16Array<T>
impl<'cx, T> TryFromJs<'cx> for Int16Array<T>
type Error = TypeExpected<JsTypedArray<i16>>
Source§impl<'cx, T> TryFromJs<'cx> for Int32Array<T>
impl<'cx, T> TryFromJs<'cx> for Int32Array<T>
type Error = TypeExpected<JsTypedArray<i32>>
Source§impl<'cx, T> TryFromJs<'cx> for Json<T>where
for<'de> T: Deserialize<'de>,
Available on crate feature serde
only.
impl<'cx, T> TryFromJs<'cx> for Json<T>where
for<'de> T: Deserialize<'de>,
Available on crate feature
serde
only.