neon::types::extract

Trait TryFromJs

source
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§

source

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§

source

fn from_js(cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>) -> NeonResult<Self>

Same as TryFromJs, but all errors are converted to JavaScript exceptions

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'cx> TryFromJs<'cx> for bool

source§

type Error = TypeExpected<JsBoolean>

source§

fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>

source§

impl<'cx> TryFromJs<'cx> for f64

source§

type Error = TypeExpected<JsNumber>

source§

fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>

source§

impl<'cx> TryFromJs<'cx> for ()

source§

type Error = Infallible

source§

fn try_from_js( _cx: &mut Cx<'cx>, _v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>

source§

impl<'cx> TryFromJs<'cx> for String

source§

type Error = TypeExpected<JsString>

source§

fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>

source§

impl<'cx, L, R> TryFromJs<'cx> for Either<L, R>
where L: TryFromJs<'cx>, R: TryFromJs<'cx>,

source§

type Error = Error<<L as TryFromJs<'cx>>::Error, <R as TryFromJs<'cx>>::Error>

source§

fn try_from_js( cx: &mut Cx<'cx>, v: Handle<'cx, JsValue>, ) -> NeonResult<Result<Self, Self::Error>>

source§

impl<'cx, T> TryFromJs<'cx> for Option<T>
where T: TryFromJs<'cx>,

source§

type Error = <T as TryFromJs<'cx>>::Error

source§

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>
where JsTypedArray<T>: Value, T: Binary,

source§

type Error = TypeExpected<JsTypedArray<T>>

source§

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

source§

impl<'cx> TryFromJs<'cx> for Buffer

source§

impl<'cx> TryFromJs<'cx> for Date

Available on crate feature napi-5 only.
source§

impl<'cx, O> TryFromJs<'cx> for Root<O>
where O: Object,

source§

impl<'cx, T> TryFromJs<'cx> for Json<T>
where for<'de> T: Deserialize<'de>,

Available on crate feature serde only.
source§

impl<'cx, T> TryFromJs<'cx> for Boxed<T>
where T: Clone + 'static,

source§

impl<'cx, V> TryFromJs<'cx> for Handle<'cx, V>
where V: Value,