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 ArrayBuffer
impl<'cx> TryFromJs<'cx> for ArrayBuffer
type Error = TypeExpected<JsBuffer>
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, 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.