JSTypedArray

Struct JSTypedArray 

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

A JavaScript Typed Array object.

Implementations§

Source§

impl<'a> JSTypedArray<'a>

Source

pub fn new( ctx: &'a JSContext, array_type: JSTypedArrayType, length: usize, ) -> Result<Self, JSValue<'a>>

Creates a Javascript Typed Array object with the given number of elements all initialized to zero.

Returns Err if an exception occurred while creating the object.

Source

pub fn new_copy_from_bytes( ctx: &'a JSContext, array_type: JSTypedArrayType, bytes: &[u8], ) -> Result<Self, JSValue<'a>>

Creates a JavaScript Typed Array object from existing bytes buffer.

This will copy the bytes and manages its memory.

Returns Err if an exception occurred while creating the object.

Source

pub fn len(&self) -> Result<usize, JSValue<'a>>

Returns the length of a JavaScript Typed Array object.

Returns Err if an exception occurred while getting the length.

Source

pub fn is_empty(&self) -> Result<bool, JSValue<'a>>

Returns whether the JavaScript Typed Array object is empty.

Returns Err if an exception occurred while getting the length.

Source

pub fn byte_length(&self) -> Result<usize, JSValue<'a>>

Returns the byte length of a JavaScript Typed Array object.

Returns Err if an exception occurred while getting the byte length.

Source

pub fn byte_offset(&self) -> Result<usize, JSValue<'a>>

Returns the byte offset of a JavaScript Typed Array object.

Returns Err if an exception occurred while getting the byte offset.

Source

pub fn ty(&self) -> Result<JSTypedArrayType, JSValue<'a>>

Returns the type of a JavaScript Typed Array object.

Returns Err if an exception occurred while getting the type, or JSTypedArrayType::None if object isn’t a Typed Array.

Methods from Deref<Target = JSValue<'a>>§

Source

pub fn get_type(&self) -> JSType

Returns a JavaScript value’s type.

Source

pub fn is_undefined(&self) -> bool

Returns true if the value is undefined.

Source

pub fn is_null(&self) -> bool

Returns true if the value is null.

Source

pub fn is_date(&self) -> bool

Returns true if the value is a JavaScript date object.

Source

pub fn is_array(&self) -> bool

Returns true if the value is a JavaScript array.

Source

pub fn is_symbol(&self) -> bool

Returns true if the value’s type is the symbol type

Source

pub fn is_object(&self) -> bool

Returns true if the value is an object.

Source

pub fn is_string(&self) -> bool

Returns true if the value is a string.

Source

pub fn is_number(&self) -> bool

Returns true if the value is a number.

Source

pub fn is_boolean(&self) -> bool

Returns true if the value is a boolean.

Source

pub fn is_typed_array(&self) -> bool

Returns true if the value is a Typed Array.

Source

pub fn as_object(&self) -> Result<JSObject<'a>, JSValue<'a>>

Converts a JavaScript value to object.

Returns an Err if an exception is thrown.

Source

pub fn as_string(&self) -> Result<JSString, JSValue<'a>>

Converts a JavaScript value to string.

Returns an Err if an exception is thrown.

Source

pub fn as_number(&self) -> Result<f64, JSValue<'a>>

Converts a JavaScript value to number.

Returns an Err if an exception is thrown.

Source

pub fn as_boolean(&self) -> bool

Converts a JavaScript value to boolean.

Source

pub fn as_typed_array(&self) -> Result<JSTypedArray<'a>, JSValue<'a>>

Converts a JavaScript value to a typed array.

Returns an Err if the value is not a typed array, or if an exception is thrown.

Source

pub fn to_json_string(&self) -> Result<JSString, JSValue<'a>>

Converts a JavaScript value to JSON serialized representation of a JS value.

Returns an Err if an exception is thrown.

Trait Implementations§

Source§

impl<'a> AsJSValue<'a> for JSTypedArray<'a>

Source§

fn into_value(self) -> JSValue<'a>

Source§

fn as_value(&self) -> &JSValue<'a>

Source§

impl<'a> AsRef<JSValue<'a>> for JSTypedArray<'a>

Source§

fn as_ref(&self) -> &JSValue<'a>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Clone for JSTypedArray<'a>

Source§

fn clone(&self) -> JSTypedArray<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for JSTypedArray<'a>

Source§

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

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

impl<'a> Deref for JSTypedArray<'a>

Source§

type Target = JSValue<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for JSTypedArray<'a>

§

impl<'a> RefUnwindSafe for JSTypedArray<'a>

§

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

§

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

§

impl<'a> Unpin for JSTypedArray<'a>

§

impl<'a> UnwindSafe for JSTypedArray<'a>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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 = 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.