Struct rquickjs_core::Array

source ·
#[repr(transparent)]
pub struct Array<'js>(_);
Expand description

Rust representation of a javascript object optimized as an array.

Javascript array’s are objects and can be used as such. However arrays in quickjs are optimized when they do not have any holes. This value represents such a optimized array.

Implementations§

source§

impl<'js> Array<'js>

source

pub fn new(ctx: Ctx<'js>) -> Result<Self>

source

pub fn len(&self) -> usize

Get the lenght of the javascript array.

source

pub fn is_empty(&self) -> bool

Returns wether a javascript array is empty.

source

pub fn get<V: FromJs<'js>>(&self, idx: usize) -> Result<V>

Get the value at an index in the javascript array.

source

pub fn set<V: IntoJs<'js>>(&self, idx: usize, val: V) -> Result<()>

Set the value at an index in the javascript array.

source

pub fn iter<T: FromJs<'js>>(&self) -> ArrayIter<'js, T>

Get iterator over elments of an array

source

pub fn as_object(&self) -> &Object<'js>

Reference as an object

source

pub fn into_object(self) -> Object<'js>

Convert into an object

source

pub fn from_object(object: Object<'js>) -> Result<Self>

Convert from an object

source§

impl<'js> Array<'js>

source

pub fn as_value(&self) -> &Value<'js>

Reference to value

source

pub fn into_value(self) -> Value<'js>

Convert into value

source

pub fn from_value(value: Value<'js>) -> Result<Self>

Convert from value

Methods from Deref<Target = Value<'js>>§

source

pub fn as_bool(&self) -> Option<bool>

Try get bool from value

source

pub fn as_int(&self) -> Option<i32>

Try get int from value

source

pub fn as_float(&self) -> Option<f64>

Try get float from value

source

pub fn as_number(&self) -> Option<f64>

Try get any number from value

source

pub fn is_null(&self) -> bool

source

pub fn is_undefined(&self) -> bool

source

pub fn is_bool(&self) -> bool

Check if the value is a bool

source

pub fn is_int(&self) -> bool

Check if the value is an int

source

pub fn is_float(&self) -> bool

Check if the value is a float

source

pub fn is_number(&self) -> bool

Check if the value is an any number

source

pub fn is_string(&self) -> bool

Check if the value is a string

source

pub fn is_symbol(&self) -> bool

Check if the value is a symbol

source

pub fn is_object(&self) -> bool

Check if the value is an object

source

pub fn is_module(&self) -> bool

Check if the value is a module

source

pub fn is_array(&self) -> bool

Check if the value is an array

source

pub fn is_function(&self) -> bool

Check if the value is a function

source

pub fn is_error(&self) -> bool

Check if the value is an error

source

pub fn as_value(&self) -> &Self

Reference as value

source

pub fn get<T: FromJs<'js>>(&self) -> Result<T>

Convert from value to specified type

source

pub fn type_of(&self) -> Type

Get the type of value

source

pub fn type_name(&self) -> &'static str

Get the name of type

source

pub unsafe fn ref_string(&self) -> &String<'js>

Interprete as

Safety

You should be sure that the value already is of required type before to do it.

source

pub fn as_string(&self) -> Option<&String<'js>>

Try reinterprete as

source

pub unsafe fn ref_symbol(&self) -> &Symbol<'js>

Interprete as

Safety

You should be sure that the value already is of required type before to do it.

source

pub fn as_symbol(&self) -> Option<&Symbol<'js>>

Try reinterprete as

source

pub unsafe fn ref_object(&self) -> &Object<'js>

Interprete as

Safety

You should be sure that the value already is of required type before to do it.

source

pub fn as_object(&self) -> Option<&Object<'js>>

Try reinterprete as

source

pub unsafe fn ref_array(&self) -> &Array<'js>

Interprete as

Safety

You should be sure that the value already is of required type before to do it.

source

pub fn as_array(&self) -> Option<&Array<'js>>

Try reinterprete as

source

pub unsafe fn ref_function(&self) -> &Function<'js>

Interprete as

Safety

You should be sure that the value already is of required type before to do it.

source

pub fn as_function(&self) -> Option<&Function<'js>>

Try reinterprete as

source

pub unsafe fn ref_big_int(&self) -> &BigInt<'js>

Interprete as

Safety

You should be sure that the value already is of required type before to do it.

source

pub fn as_big_int(&self) -> Option<&BigInt<'js>>

Try reinterprete as

Trait Implementations§

source§

impl<'js> AsRef<Value<'js>> for Array<'js>

source§

fn as_ref(&self) -> &Value<'js>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'js> Clone for Array<'js>

source§

fn clone(&self) -> Array<'js>

Returns a copy 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<'js> Debug for Array<'js>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'js> Deref for Array<'js>

§

type Target = Value<'js>

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<'js> From<Array<'js>> for Value<'js>

source§

fn from(value: Array<'js>) -> Self

Converts to this type from the input type.
source§

impl<'js, A> FromIteratorJs<'js, A> for Array<'js>where A: IntoJs<'js>,

§

type Item = Value<'js>

source§

fn from_iter_js<T>(ctx: Ctx<'js>, iter: T) -> Result<Self>where T: IntoIterator<Item = A>,

source§

impl<'js> FromJs<'js> for Array<'js>

source§

fn from_js(_: Ctx<'js>, value: Value<'js>) -> Result<Self>

source§

impl<'js> IntoAtom<'js> for Array<'js>

source§

fn into_atom(self, ctx: Ctx<'js>) -> Result<Atom<'js>>

source§

impl<'js> IntoIterator for Array<'js>

§

type Item = Result<Value<'js>, Error>

The type of the elements being iterated over.
§

type IntoIter = ArrayIter<'js, Value<'js>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'js> IntoJs<'js> for Array<'js>

source§

fn into_js(self, _: Ctx<'js>) -> Result<Value<'js>>

source§

impl<'js, 't> Outlive<'t> for Array<'js>

§

type Target = Array<'t>

The target which has the same type as a Self but with another lifetime 't
source§

impl<'js> PartialEq<Array<'js>> for Array<'js>

source§

fn eq(&self, other: &Array<'js>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'js> StructuralPartialEq for Array<'js>

Auto Trait Implementations§

§

impl<'js> RefUnwindSafe for Array<'js>

§

impl<'js> Send for Array<'js>

§

impl<'js> !Sync for Array<'js>

§

impl<'js> Unpin for Array<'js>

§

impl<'js> !UnwindSafe for Array<'js>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<'js, T> AsProperty<'js, T> for Twhere T: IntoJs<'js>,

source§

fn config( self, ctx: Ctx<'js> ) -> Result<(i32, Value<'js>, Value<'js>, Value<'js>), Error>

Available on crate feature properties only.
Property configuration Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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<'js, T> IntoInput<'js> for Twhere T: IntoJs<'js>,

source§

fn num_args(&self) -> usize

Get actual number of arguments
source§

fn into_input(self, input: &mut CallInput<'js>) -> Result<(), Error>

Put the value into inputs
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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> ParallelSend for T