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§
Object Safety§
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.