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".
Implementations on Foreign Types§
Source§impl<'cx, T: 'static> TryFromJs<'cx> for &'cx RefCell<T>
impl<'cx, T: 'static> TryFromJs<'cx> for &'cx RefCell<T>
type Error = TypeExpected<JsBox<RefCell<T>>>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx, T: 'static> TryFromJs<'cx> for Arc<T>
impl<'cx, T: 'static> TryFromJs<'cx> for Arc<T>
type Error = TypeExpected<JsBox<Arc<T>>>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx, T: 'static> TryFromJs<'cx> for Rc<T>
impl<'cx, T: 'static> TryFromJs<'cx> for Rc<T>
type Error = TypeExpected<JsBox<Rc<T>>>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx, T: 'static> TryFromJs<'cx> for Ref<'cx, T>
impl<'cx, T: 'static> TryFromJs<'cx> for Ref<'cx, T>
type Error = TypeExpected<JsBox<RefCell<T>>>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Source§impl<'cx, T: 'static> TryFromJs<'cx> for RefMut<'cx, T>
impl<'cx, T: 'static> TryFromJs<'cx> for RefMut<'cx, T>
type Error = TypeExpected<JsBox<RefCell<T>>>
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>>
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> 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 i32
impl<'cx> TryFromJs<'cx> for i32
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 u32
impl<'cx> TryFromJs<'cx> for u32
type Error = TypeExpected<JsNumber>
fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>
Implementors§
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 Array<T>
impl<'cx, T> TryFromJs<'cx> for Array<T>
type Error = ArrayError<<<T as IntoIterator>::Item as TryFromJs<'cx>>::Error>
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.