Trait mozjs::conversions::FromJSValConvertible

source ·
pub trait FromJSValConvertible: Sized {
    type Config;

    // Required method
    unsafe fn from_jsval(
        cx: *mut JSContext,
        val: HandleValue<'_>,
        option: Self::Config,
    ) -> Result<ConversionResult<Self>, ()>;
}
Expand description

A trait to convert JSVals to Rust types.

Required Associated Types§

source

type Config

Optional configurable behaviour switch; use () for no configuration.

Required Methods§

source

unsafe fn from_jsval( cx: *mut JSContext, val: HandleValue<'_>, option: Self::Config, ) -> Result<ConversionResult<Self>, ()>

Convert val to type Self. Optional configuration of type T can be passed as the option argument. If it returns Err(()), a JSAPI exception is pending. If it returns Ok(Failure(reason)), there is no pending JSAPI exception.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FromJSValConvertible for bool

source§

type Config = ()

source§

unsafe fn from_jsval( _cx: *mut JSContext, val: HandleValue<'_>, _option: (), ) -> Result<ConversionResult<bool>, ()>

source§

impl FromJSValConvertible for f32

source§

type Config = ()

source§

unsafe fn from_jsval( cx: *mut JSContext, val: HandleValue<'_>, _option: (), ) -> Result<ConversionResult<f32>, ()>

source§

impl FromJSValConvertible for f64

source§

type Config = ()

source§

unsafe fn from_jsval( cx: *mut JSContext, val: HandleValue<'_>, _option: (), ) -> Result<ConversionResult<f64>, ()>

source§

impl FromJSValConvertible for i8

source§

impl FromJSValConvertible for i16

source§

impl FromJSValConvertible for i32

source§

impl FromJSValConvertible for i64

source§

impl FromJSValConvertible for *mut Symbol

source§

impl FromJSValConvertible for *mut JSObject

source§

impl FromJSValConvertible for u8

source§

impl FromJSValConvertible for u16

source§

impl FromJSValConvertible for u32

source§

impl FromJSValConvertible for u64

source§

impl FromJSValConvertible for String

source§

impl<C: Clone, T: FromJSValConvertible<Config = C>> FromJSValConvertible for Vec<T>

source§

type Config = C

source§

unsafe fn from_jsval( cx: *mut JSContext, value: HandleValue<'_>, option: C, ) -> Result<ConversionResult<Vec<T>>, ()>

source§

impl<T: FromJSValConvertible> FromJSValConvertible for Option<T>

Implementors§