Struct rquickjs::ArrayBuffer
source · #[repr(transparent)]pub struct ArrayBuffer<'js>(_);
array-buffer
only.Expand description
Rust representation of a javascript object of class ArrayBuffer.
Implementations§
source§impl<'js> ArrayBuffer<'js>
impl<'js> ArrayBuffer<'js>
sourcepub fn new<T>(
ctx: Ctx<'js>,
src: impl Into<Vec<T, Global>>
) -> Result<ArrayBuffer<'js>, Error>where
T: Copy,
pub fn new<T>( ctx: Ctx<'js>, src: impl Into<Vec<T, Global>> ) -> Result<ArrayBuffer<'js>, Error>where T: Copy,
Create array buffer from vector data
sourcepub fn new_copy<T>(
ctx: Ctx<'js>,
src: impl AsRef<[T]>
) -> Result<ArrayBuffer<'js>, Error>where
T: Copy,
pub fn new_copy<T>( ctx: Ctx<'js>, src: impl AsRef<[T]> ) -> Result<ArrayBuffer<'js>, Error>where T: Copy,
Create array buffer from slice
sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
Returns the underlying bytes of the buffer,
Returns None if the array is detached.
sourcepub fn as_slice<T>(&self) -> Option<&[T]>where
T: TypedArrayItem,
pub fn as_slice<T>(&self) -> Option<&[T]>where T: TypedArrayItem,
Returns a slice if the buffer underlying buffer is properly aligned for the type and the buffer is not detached.
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<ArrayBuffer<'js>, Error>
pub fn from_value(value: Value<'js>) -> Result<ArrayBuffer<'js>, Error>
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<ArrayBuffer<'js>, Error>
pub fn from_object(object: Object<'js>) -> Result<ArrayBuffer<'js>, Error>
Convert from an object
Methods from Deref<Target = Object<'js>>§
sourcepub fn prop<K, V, P>(&self, key: K, prop: V) -> Result<(), Error>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<(), Error>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();
sourcepub fn init_def<T>(&self) -> Result<(), Error>where
T: ObjectDef,
pub fn init_def<T>(&self) -> Result<(), Error>where T: ObjectDef,
Initialize an object using ObjectDef
sourcepub fn get<K, V>(&self, k: K) -> Result<V, Error>where
K: IntoAtom<'js>,
V: FromJs<'js>,
pub fn get<K, V>(&self, k: K) -> Result<V, Error>where K: IntoAtom<'js>, V: FromJs<'js>,
Get a new value
sourcepub fn contains_key<K>(&self, k: K) -> Result<bool, Error>where
K: IntoAtom<'js>,
pub fn contains_key<K>(&self, k: K) -> Result<bool, Error>where K: IntoAtom<'js>,
check wether the object contains a certain key.
sourcepub fn set<K, V>(&self, key: K, value: V) -> Result<(), Error>where
K: IntoAtom<'js>,
V: IntoJs<'js>,
pub fn set<K, V>(&self, key: K, value: V) -> Result<(), Error>where K: IntoAtom<'js>, V: IntoJs<'js>,
Set a member of an object to a certain value
sourcepub fn remove<K>(&self, key: K) -> Result<(), Error>where
K: IntoAtom<'js>,
pub fn remove<K>(&self, key: K) -> Result<(), Error>where K: IntoAtom<'js>,
Remove a member of an object
sourcepub fn keys<K>(&self) -> ObjectKeysIter<'js, K> ⓘwhere
K: FromAtom<'js>,
pub fn keys<K>(&self) -> ObjectKeysIter<'js, K> ⓘwhere K: FromAtom<'js>,
Get own string enumerable property names of an object
sourcepub fn own_keys<K>(&self, filter: Filter) -> ObjectKeysIter<'js, K> ⓘwhere
K: FromAtom<'js>,
pub fn own_keys<K>(&self, filter: Filter) -> ObjectKeysIter<'js, K> ⓘwhere K: FromAtom<'js>,
Get own property names of an object
sourcepub fn props<K, V>(&self) -> ObjectIter<'js, K, V> ⓘwhere
K: FromAtom<'js>,
V: FromJs<'js>,
pub fn props<K, V>(&self) -> ObjectIter<'js, K, V> ⓘwhere K: FromAtom<'js>, V: FromJs<'js>,
Get own string enumerable properties of an object
sourcepub fn own_props<K, V>(&self, filter: Filter) -> ObjectIter<'js, K, V> ⓘwhere
K: FromAtom<'js>,
V: FromJs<'js>,
pub fn own_props<K, V>(&self, filter: Filter) -> ObjectIter<'js, K, V> ⓘwhere K: FromAtom<'js>, V: FromJs<'js>,
Get own properties of an object
sourcepub fn values<K>(&self) -> ObjectValuesIter<'js, K> ⓘwhere
K: FromAtom<'js>,
pub fn values<K>(&self) -> ObjectValuesIter<'js, K> ⓘwhere K: FromAtom<'js>,
Get own string enumerable property values of an object
sourcepub fn own_values<K>(&self, filter: Filter) -> ObjectValuesIter<'js, K> ⓘwhere
K: FromAtom<'js>,
pub fn own_values<K>(&self, filter: Filter) -> ObjectValuesIter<'js, K> ⓘwhere K: FromAtom<'js>,
Get own property values of an object
sourcepub fn get_prototype(&self) -> Result<Object<'js>, Error>
pub fn get_prototype(&self) -> Result<Object<'js>, Error>
Get 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>(&self) -> boolwhere
C: ClassDef,
Available on crate feature classes
only.
pub fn instance_of<C>(&self) -> boolwhere C: ClassDef,
classes
only.Check the object for instance of
Methods from Deref<Target = Value<'js>>§
pub fn is_null(&self) -> bool
pub fn is_undefined(&self) -> bool
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if the value is a function
sourcepub fn get<T>(&self) -> Result<T, Error>where
T: FromJs<'js>,
pub fn get<T>(&self) -> Result<T, Error>where T: FromJs<'js>,
Convert from value to specified type
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
sourcepub unsafe fn ref_big_int(&self) -> &BigInt<'js>
pub unsafe fn ref_big_int(&self) -> &BigInt<'js>
sourcepub fn as_big_int(&self) -> Option<&BigInt<'js>>
pub fn as_big_int(&self) -> Option<&BigInt<'js>>
Try reinterprete as
Trait Implementations§
source§impl<'js, T> AsRef<[T]> for ArrayBuffer<'js>where
T: TypedArrayItem,
impl<'js, T> AsRef<[T]> for ArrayBuffer<'js>where T: TypedArrayItem,
source§impl<'js> AsRef<Object<'js>> for ArrayBuffer<'js>
impl<'js> AsRef<Object<'js>> for ArrayBuffer<'js>
source§impl<'js> AsRef<Value<'js>> for ArrayBuffer<'js>
impl<'js> AsRef<Value<'js>> for ArrayBuffer<'js>
source§impl<'js> Clone for ArrayBuffer<'js>
impl<'js> Clone for ArrayBuffer<'js>
source§fn clone(&self) -> ArrayBuffer<'js>
fn clone(&self) -> ArrayBuffer<'js>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'js> Debug for ArrayBuffer<'js>
impl<'js> Debug for ArrayBuffer<'js>
source§impl<'js> Deref for ArrayBuffer<'js>
impl<'js> Deref for ArrayBuffer<'js>
source§impl<'js> FromJs<'js> for ArrayBuffer<'js>
impl<'js> FromJs<'js> for ArrayBuffer<'js>
source§impl<'js> IntoJs<'js> for ArrayBuffer<'js>
impl<'js> IntoJs<'js> for ArrayBuffer<'js>
source§impl<'js, 't> Outlive<'t> for ArrayBuffer<'js>
impl<'js, 't> Outlive<'t> for ArrayBuffer<'js>
§type Target = ArrayBuffer<'t>
type Target = ArrayBuffer<'t>
Self
but with another lifetime 't
source§impl<'js> PartialEq<ArrayBuffer<'js>> for ArrayBuffer<'js>
impl<'js> PartialEq<ArrayBuffer<'js>> for ArrayBuffer<'js>
source§fn eq(&self, other: &ArrayBuffer<'js>) -> bool
fn eq(&self, other: &ArrayBuffer<'js>) -> bool
self
and other
values to be equal, and is used
by ==
.