[go: up one dir, main page]

Struct JsVar

Source
pub struct JsVar(/* private fields */);
Expand description

A JavaScript variable.

Implementations§

Source§

impl JsVar

Source

pub unsafe fn into_promise<T: From<JsVar>>(self) -> JsPromise<T>

Assume the JavaScript variable is a promise, and convert to a JsPromise.

Source

pub unsafe fn into_fn(self) -> JsFn

Assuming the JavaScript variable is a function with two parameters, convert into a JsFn.

Source

pub fn from_i32(value: i32) -> JsVar

Create a new JsVar from a Rust integer

Source

pub unsafe fn into_i32(&self) -> i32

Get a Rust integer from a JsVar.

Source

pub fn from_f32(value: f32) -> JsVar

Create a new JsVar from a Rust float

Source

pub unsafe fn into_f32(&self) -> f32

Get a Rust float from a JsVar.

Source

pub fn from_f64(value: f64) -> JsVar

Create a new JsVar from a Rust float

Source

pub unsafe fn into_f64(&self) -> f64

Get a Rust float from a JsVar.

Source

pub unsafe fn read_utf16(&self, output: &mut Vec<u16>)

Assume the variable is a string and copy into Rust Vec.

Source

pub unsafe fn read_bytes(&self, output: &mut Vec<u8>)

Assume the variable is an array and copy into Rust Vec.

Source

pub unsafe fn read_ints(&self, output: &mut Vec<i32>)

Assume the variable is an array and copy into Rust Vec.

Source

pub unsafe fn read_floats(&self, output: &mut Vec<f32>)

Assume the variable is an array and copy into Rust Vec.

Source

pub unsafe fn read_doubles(&self, output: &mut Vec<f64>)

Assume the variable is an array and copy into Rust Vec.

Source

pub unsafe fn write_bytes(&self, input: &[u8])

Assume the variable is an array and copy from Rust slice.

Source

pub unsafe fn write_ints(&self, input: &[i32])

Assume the variable is an array and copy from Rust slice.

Source

pub unsafe fn write_floats(&self, input: &[f32])

Assume the variable is an array and copy from Rust slice.

Source

pub unsafe fn write_doubles(&self, input: &[f64])

Assume the variable is an array and copy from Rust slice.

Trait Implementations§

Source§

impl Debug for JsVar

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for JsVar

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for JsVar

§

impl RefUnwindSafe for JsVar

§

impl Send for JsVar

§

impl Sync for JsVar

§

impl Unpin for JsVar

§

impl UnwindSafe for JsVar

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<'a, T> DynBoxFut<'a> for T

Source§

fn box_fut(this: &'a mut Pin<Box<dyn Future<Output = T>>>) -> DynFuture<'a, T>

std feature required. Turn a boxed future trait object into a future. This is useful for .select()ing on a slice of boxed future trait objects.
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.