quickjs_rusty::value

Struct OwnedJsObject

Source
pub struct OwnedJsObject { /* private fields */ }
Expand description

Wraps an object from the QuickJs runtime. Provides convenience property accessors.

Implementations§

Source§

impl OwnedJsObject

Source

pub fn try_from_value(value: OwnedJsValue) -> Result<Self, ValueError>

Source

pub fn into_value(self) -> OwnedJsValue

Source

pub fn properties_iter(&self) -> Result<OwnedJsPropertyIterator, ValueError>

Source

pub fn property( &self, name: &str, ) -> Result<Option<OwnedJsValue>, ExecutionError>

Source

pub fn property_require( &self, name: &str, ) -> Result<OwnedJsValue, ExecutionError>

Source

pub fn is_promise(&self) -> Result<bool, ExecutionError>

Determine if the object is a promise by checking the presence of a ‘then’ and a ‘catch’ property.

Source

pub fn set_property( &self, name: &str, value: OwnedJsValue, ) -> Result<(), ExecutionError>

Methods from Deref<Target = OwnedJsValue>§

Source

pub fn context(&self) -> *mut JSContext

Source

pub fn tag(&self) -> JsTag

Source

pub unsafe fn as_inner(&self) -> &JSValue

Get the inner JSValue without increasing ref count.

Unsafe because the caller must ensure proper memory management.

Source

pub fn is_null(&self) -> bool

Check if this value is null.

Source

pub fn is_undefined(&self) -> bool

Check if this value is undefined.

Source

pub fn is_bool(&self) -> bool

Check if this value is bool.

Source

pub fn is_int(&self) -> bool

Check if this value is int.

Source

pub fn is_float(&self) -> bool

Check if this value is float.

Source

pub fn is_exception(&self) -> bool

Check if this value is a Javascript exception.

Source

pub fn is_object(&self) -> bool

Check if this value is a Javascript object.

Source

pub fn is_array(&self) -> bool

Check if this value is a Javascript array.

Source

pub fn is_function(&self) -> bool

Check if this value is a Javascript function.

Source

pub fn is_promise(&self) -> bool

Check if this value is a Javascript promise.

Source

pub fn is_module(&self) -> bool

Check if this value is a Javascript module.

Source

pub fn is_string(&self) -> bool

Check if this value is a Javascript string.

Source

pub fn is_compiled_function(&self) -> bool

Check if this value is a bytecode compiled function.

Source

pub fn to_bool(&self) -> Result<bool, ValueError>

Convert this value into a bool

Source

pub fn to_int(&self) -> Result<i32, ValueError>

Convert this value into an i32

Source

pub fn to_float(&self) -> Result<f64, ValueError>

Convert this value into an f64

Source

pub fn to_string(&self) -> Result<String, ValueError>

Convert this value into a string

Source

pub fn to_array(&self) -> Result<OwnedJsArray, ValueError>

Source

pub fn to_date(&self) -> Result<DateTime<Utc>, ValueError>

Source

pub fn to_bigint(&self) -> Result<BigInt, ValueError>

Source

pub fn js_to_string(&self) -> Result<String, ExecutionError>

Call the Javascript .toString() method on this value.

Source

pub fn to_json_string(&self, space: u8) -> Result<String, ExecutionError>

Call the Javascript JSON.stringify() method on this value.

Trait Implementations§

Source§

impl Clone for OwnedJsObject

Source§

fn clone(&self) -> OwnedJsObject

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 Debug for OwnedJsObject

Source§

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

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

impl Deref for OwnedJsObject

Source§

type Target = OwnedJsValue

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl PartialEq for OwnedJsObject

Source§

fn eq(&self, other: &OwnedJsObject) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<OwnedJsValue> for OwnedJsObject

Source§

type Error = ValueError

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

fn try_from(value: OwnedJsValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for OwnedJsObject

Auto Trait Implementations§

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 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<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> 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.