Skip to main content

JSArrayBuffer

Struct JSArrayBuffer 

Source
pub struct JSArrayBuffer<V: JSValueImpl> { /* private fields */ }

Implementations§

Source§

impl<V> JSArrayBuffer<V>

Source

pub fn from_bytes(ctx: &JSContext<V::Context>, bytes: &[u8]) -> JSResult<Self>

Create a new ArrayBuffer by copying the provided bytes.

Source

pub fn from_bytes_owned<B: Into<Vec<u8>>>( ctx: &JSContext<V::Context>, data: B, ) -> JSResult<Self>

Create a new ArrayBuffer from owned bytes.

Source

pub fn len(&self) -> usize

Get the byte length of the ArrayBuffer.

Source

pub fn is_empty(&self) -> bool

Check if the ArrayBuffer is empty.

Source

pub fn as_slice(&self) -> &[u8]

Get a safe slice view of the ArrayBuffer’s data.

Source

pub fn as_bytes(&self) -> &[u8]

Get a reference to the ArrayBuffer’s raw bytes.

Source

pub fn as_mut_slice(&mut self) -> &mut [u8]

Get a mutable slice view of the ArrayBuffer’s data.

Source

pub fn slice(&self, start: usize, end: usize) -> &[u8]

Get a slice of the ArrayBuffer from start to end.

Source

pub fn to_vec(&self) -> Vec<u8>

Copy the contents of the ArrayBuffer into a new Vec.

Source

pub fn element_count<T>(&self) -> JSResult<usize>

Compute how many T elements this buffer can represent when aligned.

Source

pub fn validate_alignment<T>(&self, offset: usize) -> bool

Validate if the given byte offset is properly aligned for T.

Source

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>>§

Source

pub fn borrow<T>(&self) -> JSResult<Ref<'_, T>>
where T: JSClass<V>,

Borrow the underlying data from an instance

Source

pub fn borrow_mut<T>(&self) -> JSResult<RefMut<'_, T>>
where T: JSClass<V>,

Mutably borrow the underlying data from an instance

Source

pub fn prototype(&self, proto: JSObject<V>) -> bool

Source

pub fn to_json_string(&self) -> JSResult<String>

Convert JSObject to JSON string using JavaScript’s JSON.stringify

Source

pub fn set<'a, K, KV>(&'a self, k: K, kv: KV) -> JSResult<&'a Self>
where K: Into<PropertyKey<'a, V>>, KV: IntoJSValue<V>,

Source

pub fn define_property<'a, K>( &'a self, k: K, descriptor: PropertyDescriptor<V>, ) -> JSResult<&'a Self>
where K: Into<PropertyKey<'a, V>>,

Source

pub fn delete<'a, K>(&'a self, k: K) -> JSResult<bool>
where K: Into<PropertyKey<'a, V>>,

Source

pub fn has_property<'a, K>(&self, k: K) -> JSResult<bool>
where K: Into<PropertyKey<'a, V>>,

Source

pub fn get<'a, K, T>(&'a self, k: K) -> JSResult<T>
where K: Into<PropertyKey<'a, V>>, T: FromJSValue<V>,

Source

pub fn get_opt<'a, K, T>(&'a self, k: K) -> JSResult<Option<T>>
where K: Into<PropertyKey<'a, V>>, T: FromJSValue<V>,

Source

pub fn as_js_value(&self) -> &JSValue<V>

Source

pub fn as_mut_value(&mut self) -> &mut V

Returns a mutable reference to the underlying/raw JSValue

Source

pub fn entries(&self) -> JSResult<Vec<Entry<V>>>

Returns an iterator over the object’s own enumerable string-keyed property [key, value] pairs.

Source

pub fn entries_as<K, V2>(&self) -> JSResult<Vec<(K, V2)>>
where K: FromJSValue<V>, V2: FromJSValue<V>,

Returns entries with converted types

Source

pub fn own_keys(&self) -> JSResult<Vec<V>>

Returns an array of a given object’s own enumerable property names

Source

pub fn values(&self) -> JSResult<impl Iterator<Item = JSValue<V>> + '_>

Returns an iterator over the object’s own enumerable string-keyed property values.

Source

pub fn values_as<T>(&self) -> JSResult<Vec<T>>
where T: FromJSValue<V>,

Returns values with converted type

Source

pub fn keys(&self) -> JSResult<impl Iterator<Item = JSValue<V>> + '_>

Returns an iterator over the object’s own enumerable string-keyed property names.

Source

pub fn keys_as<K>(&self) -> JSResult<Vec<K>>
where K: FromJSValue<V>,

Returns keys with converted type

Methods from Deref<Target = JSValue<V>>§

Source

pub fn type_of(&self) -> JSValueType

Source

pub fn is_object(&self) -> bool

Source

pub fn is_array(&self) -> bool

Source

pub fn is_array_buffer(&self) -> bool

Source

pub fn is_function(&self) -> bool

Source

pub fn is_constructor(&self) -> bool

Source

pub fn is_promise(&self) -> bool

Source

pub fn is_error(&self) -> bool

Source

pub fn is_exception(&self) -> bool

Source

pub fn is_undefined(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn is_boolean(&self) -> bool

Source

pub fn is_number(&self) -> bool

Source

pub fn is_bigint(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_symbol(&self) -> bool

Source

pub fn is_date(&self) -> bool

Source

pub fn is_proxy(&self) -> bool

Source

pub fn as_value(&self) -> &V

Source

pub fn context(&self) -> JSContext<V::Context>

Returns the context associated with this value.

Trait Implementations§

Source§

impl<V: JSValueImpl> Clone for JSArrayBuffer<V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: JSValueImpl> Deref for JSArrayBuffer<V>

Source§

type Target = JSObject<V>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<V: JSValueImpl> DerefMut for JSArrayBuffer<V>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<V> FromJSValue<V> for JSArrayBuffer<V>
where V: JSTypeOf,

Source§

fn from_js_value( ctx: &JSContext<V::Context>, value: JSValue<V>, ) -> JSResult<Self>

Source§

impl<V> IntoJSValue<V> for JSArrayBuffer<V>
where V: JSValueImpl,

Source§

fn into_js_value(self, _ctx: &JSContext<V::Context>) -> JSValue<V>

Source§

impl<V: JSValueImpl> JSParameterType for JSArrayBuffer<V>

Auto Trait Implementations§

§

impl<V> Freeze for JSArrayBuffer<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for JSArrayBuffer<V>
where V: RefUnwindSafe,

§

impl<V> Send for JSArrayBuffer<V>
where V: Send,

§

impl<V> Sync for JSArrayBuffer<V>
where V: Sync,

§

impl<V> Unpin for JSArrayBuffer<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for JSArrayBuffer<V>
where V: UnsafeUnpin,

§

impl<V> UnwindSafe for JSArrayBuffer<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<V, T> PromiseResolver<V> for T

Source§

fn resolve_promise(self, resolve: JSFunc<V>, _reject: JSFunc<V>)

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more