pub struct JSArrayBuffer<V: JSValueImpl> { /* private fields */ }Implementations§
Source§impl<V> JSArrayBuffer<V>where
V: JSObjectOps + JSArrayBufferOps,
impl<V> JSArrayBuffer<V>where
V: JSObjectOps + JSArrayBufferOps,
Sourcepub fn from_bytes(ctx: &JSContext<V::Context>, bytes: &[u8]) -> JSResult<Self>
pub fn from_bytes(ctx: &JSContext<V::Context>, bytes: &[u8]) -> JSResult<Self>
Create a new ArrayBuffer by copying the provided bytes.
Sourcepub fn from_bytes_owned<B: Into<Vec<u8>>>(
ctx: &JSContext<V::Context>,
data: B,
) -> JSResult<Self>
pub fn from_bytes_owned<B: Into<Vec<u8>>>( ctx: &JSContext<V::Context>, data: B, ) -> JSResult<Self>
Create a new ArrayBuffer from owned bytes.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Get a mutable slice view of the ArrayBuffer’s data.
Sourcepub fn slice(&self, start: usize, end: usize) -> &[u8] ⓘ
pub fn slice(&self, start: usize, end: usize) -> &[u8] ⓘ
Get a slice of the ArrayBuffer from start to end.
Sourcepub fn element_count<T>(&self) -> JSResult<usize>where
T: TypedArrayElement,
pub fn element_count<T>(&self) -> JSResult<usize>where
T: TypedArrayElement,
Compute how many T elements this buffer can represent when aligned.
Sourcepub fn validate_alignment<T>(&self, offset: usize) -> boolwhere
T: TypedArrayElement,
pub fn validate_alignment<T>(&self, offset: usize) -> boolwhere
T: TypedArrayElement,
Validate if the given byte offset is properly aligned for T.
Sourcepub fn from_object(obj: JSObject<V>) -> Option<Self>
pub fn from_object(obj: JSObject<V>) -> Option<Self>
Construct a JSArrayBuffer from a JSObject if it is an ArrayBuffer.
Methods from Deref<Target = JSObject<V>>§
Sourcepub fn borrow<T>(&self) -> JSResult<Ref<'_, T>>where
T: JSClass<V>,
pub fn borrow<T>(&self) -> JSResult<Ref<'_, T>>where
T: JSClass<V>,
Borrow the underlying data from an instance
Sourcepub fn borrow_mut<T>(&self) -> JSResult<RefMut<'_, T>>where
T: JSClass<V>,
pub fn borrow_mut<T>(&self) -> JSResult<RefMut<'_, T>>where
T: JSClass<V>,
Mutably borrow the underlying data from an instance
pub fn prototype(&self, proto: JSObject<V>) -> bool
Sourcepub fn to_json_string(&self) -> JSResult<String>
pub fn to_json_string(&self) -> JSResult<String>
Convert JSObject to JSON string using JavaScript’s JSON.stringify
pub fn set<'a, K, KV>(&'a self, k: K, kv: KV) -> JSResult<&'a Self>
pub fn define_property<'a, K>(
&'a self,
k: K,
descriptor: PropertyDescriptor<V>,
) -> JSResult<&'a Self>where
K: Into<PropertyKey<'a, V>>,
pub fn delete<'a, K>(&'a self, k: K) -> JSResult<bool>where
K: Into<PropertyKey<'a, V>>,
pub fn has_property<'a, K>(&self, k: K) -> JSResult<bool>where
K: Into<PropertyKey<'a, V>>,
pub fn get<'a, K, T>(&'a self, k: K) -> JSResult<T>
pub fn get_opt<'a, K, T>(&'a self, k: K) -> JSResult<Option<T>>
pub fn as_js_value(&self) -> &JSValue<V>
Sourcepub fn as_mut_value(&mut self) -> &mut V
pub fn as_mut_value(&mut self) -> &mut V
Returns a mutable reference to the underlying/raw JSValue
Sourcepub fn entries(&self) -> JSResult<Vec<Entry<V>>>
pub fn entries(&self) -> JSResult<Vec<Entry<V>>>
Returns an iterator over the object’s own enumerable string-keyed property [key, value] pairs.
Sourcepub fn entries_as<K, V2>(&self) -> JSResult<Vec<(K, V2)>>where
K: FromJSValue<V>,
V2: FromJSValue<V>,
pub fn entries_as<K, V2>(&self) -> JSResult<Vec<(K, V2)>>where
K: FromJSValue<V>,
V2: FromJSValue<V>,
Returns entries with converted types
Sourcepub fn own_keys(&self) -> JSResult<Vec<V>>
pub fn own_keys(&self) -> JSResult<Vec<V>>
Returns an array of a given object’s own enumerable property names
Sourcepub fn values(&self) -> JSResult<impl Iterator<Item = JSValue<V>> + '_>
pub fn values(&self) -> JSResult<impl Iterator<Item = JSValue<V>> + '_>
Returns an iterator over the object’s own enumerable string-keyed property values.
Sourcepub fn values_as<T>(&self) -> JSResult<Vec<T>>where
T: FromJSValue<V>,
pub fn values_as<T>(&self) -> JSResult<Vec<T>>where
T: FromJSValue<V>,
Returns values with converted type
Sourcepub fn keys(&self) -> JSResult<impl Iterator<Item = JSValue<V>> + '_>
pub fn keys(&self) -> JSResult<impl Iterator<Item = JSValue<V>> + '_>
Returns an iterator over the object’s own enumerable string-keyed property names.
Sourcepub fn keys_as<K>(&self) -> JSResult<Vec<K>>where
K: FromJSValue<V>,
pub fn keys_as<K>(&self) -> JSResult<Vec<K>>where
K: FromJSValue<V>,
Returns keys with converted type