Skip to main content

JsIn

Struct JsIn 

Source
pub struct JsIn<'a> { /* private fields */ }
Expand description

A JS value borrowed for a call: read it with its methods, convert it with super::JsValue::from_js.

Implementations§

Source§

impl<'a> JsIn<'a>

Source

pub fn kind(&self) -> JsKind

What kind of value it is.

Source

pub fn as_bytes(&self) -> Option<Vec<u8>>

The bytes of a Uint8Array, copied.

Source

pub fn is_nullish(&self) -> bool

undefined or null.

Source

pub fn as_bool(&self) -> Option<bool>

The boolean it is.

Source

pub fn as_number(&self) -> Option<f64>

The number it is.

Source

pub fn as_string(&self) -> Option<String>

The string it is.

Source

pub fn array_len(&self) -> Result<Option<usize>, PropError>

Its length, if it is an array (an error when it is longer than the host reads in one call).

Source

pub fn index(&self, i: usize) -> Result<JsOwned<'a>, PropError>

Item i of the array it is.

Source

pub fn field(&self, key: &str) -> Result<JsOwned<'a>, PropError>

Its field key (undefined when it has none).

Source

pub fn keys(&self) -> Result<Vec<String>, PropError>

Its own enumerable string keys (none when it is not an object).

Source

pub fn primitives(&self) -> Result<Option<Vec<JsPrimitive>>, PropError>

The items of the array it is, as primitives (None: not an array), read in one call.

Source

pub fn primitive_entries(&self) -> Result<Vec<(String, JsPrimitive)>, PropError>

Its own enumerable string-keyed fields, as primitives (none when it is not an object), read in one call.

Source

pub fn as_date(&self) -> Option<f64>

The milliseconds since the Unix epoch of the Date it is.

Source

pub fn class(&self) -> Option<JsClass>

The class of the object it is (None: not an object).

Source

pub fn same_value(&self, other: JsIn<'_>) -> bool

Whether it is other, as Object.is says (the same object, or the same primitive: NaN is NaN, 0 is not -0).

Source

pub fn as_buffer(&self) -> Option<Vec<u8>>

The bytes of the ArrayBuffer, typed array or DataView it is, copied.

Source

pub fn iterate(&self) -> Result<Option<Vec<JsOwned<'a>>>, PropError>

The values it yields as an iterable, as for...of reads them (a Map’s [key, value] pairs, a Set’s values; None: not iterable).

Source

pub fn invoke( &self, name: &str, args: &[JsIn<'_>], ) -> Result<JsOwned<'a>, PropError>

Calls its method name with args: what it returns (a primitive’s methods too: "a".search(re)).

Source

pub fn to_json(&self) -> Result<JsonValue, PropError>

The value as JSON.

Source

pub fn describe(&self) -> String

A short text showing it, for errors.

Source

pub fn expected(&self, what: &str) -> PropError

“expected what, got ”.

Trait Implementations§

Source§

impl<'a> Clone for JsIn<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for JsIn<'a>

Source§

impl Debug for JsIn<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for JsIn<'a>

§

impl<'a> !Send for JsIn<'a>

§

impl<'a> !Sync for JsIn<'a>

§

impl<'a> !UnwindSafe for JsIn<'a>

§

impl<'a> Forget for JsIn<'a>

§

impl<'a> Freeze for JsIn<'a>
where &'a dyn JsHost: Freeze,

§

impl<'a> Move for JsIn<'a>

§

impl<'a> Unpin for JsIn<'a>
where &'a dyn JsHost: Unpin,

§

impl<'a> UnsafeUnpin for JsIn<'a>
where &'a dyn JsHost: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.