Struct rquickjs_core::TypedArray
source · [−]#[repr(transparent)]pub struct TypedArray<'js, T>(_, _);array-buffer only.Expand description
Rust representation of a javascript objects of TypedArray classes.
| ES Type | Rust Type |
|---|---|
Int8Array | TypedArray<i8> |
Uint8Array | TypedArray<u8> |
Int16Array | TypedArray<i16> |
Uint16Array | TypedArray<u16> |
Int32Array | TypedArray<i32> |
Uint32Array | TypedArray<u32> |
Float32Array | TypedArray<f32> |
Float64Array | TypedArray<f64> |
BigInt64Array | TypedArray<i64> |
BigUint64Array | TypedArray<u64> |
Implementations
sourceimpl<'js, T> TypedArray<'js, T>
impl<'js, T> TypedArray<'js, T>
sourcepub fn new(ctx: Ctx<'js>, src: impl Into<Vec<T>>) -> Result<Self> where
T: Copy + TypedArrayItem,
pub fn new(ctx: Ctx<'js>, src: impl Into<Vec<T>>) -> Result<Self> where
T: Copy + TypedArrayItem,
Create typed array from vector data
sourcepub fn new_copy(ctx: Ctx<'js>, src: impl AsRef<[T]>) -> Result<Self> where
T: Copy + TypedArrayItem,
pub fn new_copy(ctx: Ctx<'js>, src: impl AsRef<[T]>) -> Result<Self> where
T: Copy + TypedArrayItem,
Create typed array from slice
sourcepub fn into_value(self) -> Value<'js>
pub fn into_value(self) -> Value<'js>
Convert into value
sourcepub fn from_value(value: Value<'js>) -> Result<Self> where
T: TypedArrayItem,
pub fn from_value(value: Value<'js>) -> Result<Self> where
T: TypedArrayItem,
Convert from value
sourcepub fn into_object(self) -> Object<'js>
pub fn into_object(self) -> Object<'js>
Convert into an object
sourcepub fn from_object(object: Object<'js>) -> Result<Self> where
T: TypedArrayItem,
pub fn from_object(object: Object<'js>) -> Result<Self> where
T: TypedArrayItem,
Convert from an object
sourcepub fn arraybuffer(&self) -> Result<ArrayBuffer<'js>>
pub fn arraybuffer(&self) -> Result<ArrayBuffer<'js>>
Get underlaying ArrayBuffer
sourcepub fn from_arraybuffer(arraybuffer: ArrayBuffer<'js>) -> Result<Self> where
T: TypedArrayItem,
pub fn from_arraybuffer(arraybuffer: ArrayBuffer<'js>) -> Result<Self> where
T: TypedArrayItem,
Convert from an ArrayBuffer
Methods from Deref<Target = Object<'js>>
sourcepub fn init_def<T>(&self) -> Result<()> where
T: ObjectDef,
pub fn init_def<T>(&self) -> Result<()> where
T: ObjectDef,
Initialize an object using ObjectDef
sourcepub fn contains_key<K>(&self, k: K) -> Result<bool> where
K: IntoAtom<'js>,
pub fn contains_key<K>(&self, k: K) -> Result<bool> where
K: IntoAtom<'js>,
check wether the object contains a certain key.
sourcepub fn set<K: IntoAtom<'js>, V: IntoJs<'js>>(
&self,
key: K,
value: V
) -> Result<()>
pub fn set<K: IntoAtom<'js>, V: IntoJs<'js>>(
&self,
key: K,
value: V
) -> Result<()>
Set a member of an object to a certain value
sourcepub fn keys<K: FromAtom<'js>>(&self) -> ObjectKeysIter<'js, K>
pub fn keys<K: FromAtom<'js>>(&self) -> ObjectKeysIter<'js, K>
Get own string enumerable property names of an object
sourcepub fn own_keys<K: FromAtom<'js>>(
&self,
filter: Filter
) -> ObjectKeysIter<'js, K>
pub fn own_keys<K: FromAtom<'js>>(
&self,
filter: Filter
) -> ObjectKeysIter<'js, K>
Get own property names of an object
sourcepub fn props<K: FromAtom<'js>, V: FromJs<'js>>(&self) -> ObjectIter<'js, K, V>
pub fn props<K: FromAtom<'js>, V: FromJs<'js>>(&self) -> ObjectIter<'js, K, V>
Get own string enumerable properties of an object
sourcepub fn own_props<K: FromAtom<'js>, V: FromJs<'js>>(
&self,
filter: Filter
) -> ObjectIter<'js, K, V>
pub fn own_props<K: FromAtom<'js>, V: FromJs<'js>>(
&self,
filter: Filter
) -> ObjectIter<'js, K, V>
Get own properties of an object
sourcepub fn values<K: FromAtom<'js>>(&self) -> ObjectValuesIter<'js, K>
pub fn values<K: FromAtom<'js>>(&self) -> ObjectValuesIter<'js, K>
Get own string enumerable property values of an object
sourcepub fn own_values<K: FromAtom<'js>>(
&self,
filter: Filter
) -> ObjectValuesIter<'js, K>
pub fn own_values<K: FromAtom<'js>>(
&self,
filter: Filter
) -> ObjectValuesIter<'js, K>
Get own property values of an object
sourcepub fn get_prototype(&self) -> Result<Object<'js>>
pub fn get_prototype(&self) -> Result<Object<'js>>
Get an object prototype
sourcepub fn set_prototype(&self, proto: &Object<'js>) -> Result<()>
pub fn set_prototype(&self, proto: &Object<'js>) -> Result<()>
Set an object prototype
sourcepub fn is_instance_of(&self, class: impl AsRef<Value<'js>>) -> bool
pub fn is_instance_of(&self, class: impl AsRef<Value<'js>>) -> bool
Check instance of object
sourcepub fn instance_of<C: ClassDef>(&self) -> bool
Available on crate feature classes only.
pub fn instance_of<C: ClassDef>(&self) -> bool
classes only.Check the object for instance of
sourcepub fn prop<K, V, P>(&self, key: K, prop: V) -> Result<()> where
K: IntoAtom<'js>,
V: AsProperty<'js, P>,
Available on crate feature properties only.
pub fn prop<K, V, P>(&self, key: K, prop: V) -> Result<()> where
K: IntoAtom<'js>,
V: AsProperty<'js, P>,
properties only.Define a property of an object
// Define readonly property without value
obj.prop("no_val", ()).unwrap();
// Define readonly property with value
obj.prop("ro_str", "Some const text").unwrap();
// Define readonly property with value and make it to be writable
obj.prop("ro_str2", Property::from("Some const text").writable()).unwrap();
// Define readonly property using getter and make it to be enumerable
obj.prop("ro_str_get", Accessor::from(|| "Some readable text").enumerable()).unwrap();
// Define readonly property using getter and setter
obj.prop("ro_str_get_set",
Accessor::from(|| "Some text")
.set(|new_val: String| { /* do something */ })
).unwrap();Methods from Deref<Target = Value<'js>>
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if the value is a function
sourcepub unsafe fn ref_string(&self) -> &String<'js>
pub unsafe fn ref_string(&self) -> &String<'js>
sourcepub unsafe fn ref_symbol(&self) -> &Symbol<'js>
pub unsafe fn ref_symbol(&self) -> &Symbol<'js>
sourcepub unsafe fn ref_object(&self) -> &Object<'js>
pub unsafe fn ref_object(&self) -> &Object<'js>
sourcepub unsafe fn ref_function(&self) -> &Function<'js>
pub unsafe fn ref_function(&self) -> &Function<'js>
sourcepub fn as_function(&self) -> Option<&Function<'js>>
pub fn as_function(&self) -> Option<&Function<'js>>
Try reinterprete as
Trait Implementations
sourceimpl<'js, T: TypedArrayItem> AsMut<[T]> for TypedArray<'js, T>
impl<'js, T: TypedArrayItem> AsMut<[T]> for TypedArray<'js, T>
sourceimpl<'js, T: TypedArrayItem> AsRef<[T]> for TypedArray<'js, T>
impl<'js, T: TypedArrayItem> AsRef<[T]> for TypedArray<'js, T>
sourceimpl<'js, T> AsRef<Object<'js>> for TypedArray<'js, T>
impl<'js, T> AsRef<Object<'js>> for TypedArray<'js, T>
sourceimpl<'js, T> AsRef<Value<'js>> for TypedArray<'js, T>
impl<'js, T> AsRef<Value<'js>> for TypedArray<'js, T>
sourceimpl<'js, T: Clone> Clone for TypedArray<'js, T>
impl<'js, T: Clone> Clone for TypedArray<'js, T>
sourcefn clone(&self) -> TypedArray<'js, T>
fn clone(&self) -> TypedArray<'js, T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl<'js, T: Debug> Debug for TypedArray<'js, T>
impl<'js, T: Debug> Debug for TypedArray<'js, T>
sourceimpl<'js, T> Deref for TypedArray<'js, T>
impl<'js, T> Deref for TypedArray<'js, T>
sourceimpl<'js, T> FromJs<'js> for TypedArray<'js, T> where
T: TypedArrayItem,
impl<'js, T> FromJs<'js> for TypedArray<'js, T> where
T: TypedArrayItem,
sourceimpl<'js, T> IntoJs<'js> for TypedArray<'js, T>
impl<'js, T> IntoJs<'js> for TypedArray<'js, T>
sourceimpl<'js, T: PartialEq> PartialEq<TypedArray<'js, T>> for TypedArray<'js, T>
impl<'js, T: PartialEq> PartialEq<TypedArray<'js, T>> for TypedArray<'js, T>
sourcefn eq(&self, other: &TypedArray<'js, T>) -> bool
fn eq(&self, other: &TypedArray<'js, T>) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourceimpl<'js, T> TryFrom<ArrayBuffer<'js>> for TypedArray<'js, T> where
T: TypedArrayItem,
impl<'js, T> TryFrom<ArrayBuffer<'js>> for TypedArray<'js, T> where
T: TypedArrayItem,
sourceimpl<'js, T> TryFrom<TypedArray<'js, T>> for ArrayBuffer<'js>
impl<'js, T> TryFrom<TypedArray<'js, T>> for ArrayBuffer<'js>
impl<'js, T> StructuralPartialEq for TypedArray<'js, T>
Auto Trait Implementations
impl<'js, T> !RefUnwindSafe for TypedArray<'js, T>
impl<'js, T> !Send for TypedArray<'js, T>
impl<'js, T> !Sync for TypedArray<'js, T>
impl<'js, T> Unpin for TypedArray<'js, T> where
T: Unpin,
impl<'js, T> UnwindSafe for TypedArray<'js, T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more