pub struct JSTypedArray<'a> { /* private fields */ }
Expand description
A JavaScript Typed Array object.
Implementations§
Source§impl<'a> JSTypedArray<'a>
impl<'a> JSTypedArray<'a>
Sourcepub fn new(
ctx: &'a JSContext,
array_type: JSTypedArrayType,
length: usize,
) -> Result<Self, JSValue<'a>>
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.
Sourcepub fn new_copy_from_bytes(
ctx: &'a JSContext,
array_type: JSTypedArrayType,
bytes: &[u8],
) -> Result<Self, JSValue<'a>>
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.
Sourcepub fn len(&self) -> Result<usize, JSValue<'a>>
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.
Sourcepub fn is_empty(&self) -> Result<bool, JSValue<'a>>
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.
Sourcepub fn byte_length(&self) -> Result<usize, JSValue<'a>>
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.
Sourcepub fn byte_offset(&self) -> Result<usize, JSValue<'a>>
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.
Sourcepub fn ty(&self) -> Result<JSTypedArrayType, JSValue<'a>>
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>>§
Sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Returns true
if the value is undefined
.
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true
if the value is a boolean.
Sourcepub fn is_typed_array(&self) -> bool
pub fn is_typed_array(&self) -> bool
Returns true
if the value is a Typed Array.
Sourcepub fn as_object(&self) -> Result<JSObject<'a>, JSValue<'a>>
pub fn as_object(&self) -> Result<JSObject<'a>, JSValue<'a>>
Converts a JavaScript value to object.
Returns an Err
if an exception is thrown.
Sourcepub fn as_string(&self) -> Result<JSString, JSValue<'a>>
pub fn as_string(&self) -> Result<JSString, JSValue<'a>>
Converts a JavaScript value to string.
Returns an Err
if an exception is thrown.
Sourcepub fn as_number(&self) -> Result<f64, JSValue<'a>>
pub fn as_number(&self) -> Result<f64, JSValue<'a>>
Converts a JavaScript value to number.
Returns an Err
if an exception is thrown.
Sourcepub fn as_boolean(&self) -> bool
pub fn as_boolean(&self) -> bool
Converts a JavaScript value to boolean.
Sourcepub fn as_typed_array(&self) -> Result<JSTypedArray<'a>, JSValue<'a>>
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.
Trait Implementations§
Source§impl<'a> AsJSValue<'a> for JSTypedArray<'a>
impl<'a> AsJSValue<'a> for JSTypedArray<'a>
Source§impl<'a> AsRef<JSValue<'a>> for JSTypedArray<'a>
impl<'a> AsRef<JSValue<'a>> for JSTypedArray<'a>
Source§impl<'a> Clone for JSTypedArray<'a>
impl<'a> Clone for JSTypedArray<'a>
Source§fn clone(&self) -> JSTypedArray<'a>
fn clone(&self) -> JSTypedArray<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more