Struct chakracore::value::ArrayBuffer
[−]
[src]
pub struct ArrayBuffer(_);
A JavaScript array buffer.
Methods
impl ArrayBuffer
[src]
fn new(_guard: &ContextGuard, size: u32) -> Self
Creates a new array buffer with a specified size.
fn with_data<T: Sized>(_guard: &ContextGuard, data: Vec<T>) -> Self
Creates a new array buffer, owning the data.
unsafe fn from_slice<T: Sized>(_guard: &ContextGuard, data: &mut [T]) -> Self
Creates a new array buffer, wrapping external data.
This is unsafe because the object does not take ownership of the resource. Therefore the data may become a dangling pointer. The caller is responsible for keeping the reference alive.
fn as_slice(&self) -> &[u8]
Returns the underlying memory storage used by the array buffer.
This may produce unexpected results if used in conjunction with the
unsafe from_slice
.
fn is_same(value: &Value) -> bool
Returns true if the value is an ArrayBuffer
.
impl ArrayBuffer
[src]
unsafe fn from_raw(value: JsRef) -> ArrayBuffer
Creates an instance from a raw pointer.
This is used for managing the lifetime of JSRT objects. They are
tracked using reference counting; incrementing with from_raw
,
and decrementing with drop
.
This is required to support items stored on the heap, since the JSRT runtime only observes the stack.
If used in conjunction with a Property
or any Value
, it is
assumed a Context
is active.
fn as_raw(&self) -> JsRef
Returns the underlying raw pointer.
Methods from Deref<Target = Object>
fn set(&self, _guard: &ContextGuard, key: &Property, value: &Value)
Sets an object's property's value.
fn set_index(&self, guard: &ContextGuard, index: u32, value: &Value)
Sets an object's index value.
fn get(&self, _guard: &ContextGuard, key: &Property) -> Value
Returns an object's property's value.
fn get_index(&self, guard: &ContextGuard, index: u32) -> Value
Returns an object's index value.
fn delete(&self, _guard: &ContextGuard, key: &Property) -> bool
Deletes an object's property.
fn delete_index(&self, guard: &ContextGuard, index: u32)
Deletes an object's index.
fn has(&self, _guard: &ContextGuard, key: &Property) -> bool
Determines whether an object has a property.
fn has_index(&self, guard: &ContextGuard, index: u32) -> bool
Determines whether an object has a value at the specified index.
fn define_property(
&self,
_guard: &ContextGuard,
key: &Property,
desc: &Object
) -> bool
&self,
_guard: &ContextGuard,
key: &Property,
desc: &Object
) -> bool
Defines or modifies a property directly on an object.
This is equivalent to Object.defineProperty()
.
fn set_prototype(&self, _guard: &ContextGuard, prototype: &Value) -> Result<()>
Sets the object's prototype. This will result in an error if it's called on the context's global object.
fn get_prototype(&self, _guard: &ContextGuard) -> Value
Returns the object's prototype.
fn get_own_property_names(&self, _guard: &ContextGuard) -> Array
Returns the object's property names
fn prevent_extension(&self)
Makes an object non-extensible.
fn is_extensible(&self) -> bool
Returns whether the object is extensible or not.
unsafe fn set_collect_callback(&self, callback: Box<Fn(&Value)>)
Sets a callback that is executed before the object is collected.
This is highly unsafe to use. There is no bookkeeping whether any other
caller replaces the current callback or not. It is also used internally
by Function
to cleanup user data (if it's replaced, memory will leak).
Trait Implementations
impl Clone for ArrayBuffer
[src]
fn clone(&self) -> ArrayBuffer
Duplicates a reference counted type.
The underlying pointer will be copied, and its reference count will be incremented, returned wrapped as the type.
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Drop for ArrayBuffer
[src]
fn drop(&mut self)
Decrements the reference counter if the object is recyclable.