Struct rquickjs_core::Value
source · pub struct Value<'js> { /* private fields */ }
Expand description
Any JavaScript value
Implementations§
source§impl<'js> Value<'js>
impl<'js> Value<'js>
pub fn new_uninitialized(ctx: Ctx<'js>) -> Self
pub fn new_undefined(ctx: Ctx<'js>) -> Self
pub fn new_null(ctx: Ctx<'js>) -> Self
sourcepub fn new_number(ctx: Ctx<'js>, value: f64) -> Self
pub fn new_number(ctx: Ctx<'js>, value: f64) -> Self
Create a new number value
sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Returns if the value is the JavaScript undefined value.
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if the value is a function
sourcepub fn is_constructor(&self) -> bool
pub fn is_constructor(&self) -> bool
Check if the value is a constructor function
sourcepub fn is_promise(&self) -> bool
pub fn is_promise(&self) -> bool
Check if the value is a promise.
sourcepub fn is_exception(&self) -> bool
pub fn is_exception(&self) -> bool
Check if the value is an exception
sourcepub unsafe fn from_raw(ctx: Ctx<'js>, value: JSValue) -> Self
pub unsafe fn from_raw(ctx: Ctx<'js>, value: JSValue) -> Self
Create a value from the C library JavaScript value.
§Safety
The value cannot be from an unrelated runtime and the value must be owned.
QuickJS JavaScript values are reference counted. The drop implementation of this type
decrements the reference count so the value must have count which won’t be decremented
elsewhere. Use qjs::JS_DupValue
to increment the reference count of the value.
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_string(&self) -> &String<'js>
pub unsafe fn ref_string(&self) -> &String<'js>
sourcepub fn into_string(self) -> Option<String<'js>>
pub fn into_string(self) -> Option<String<'js>>
Try convert into String
sourcepub fn try_into_string(self) -> Result<String<'js>, Value<'js>>
pub fn try_into_string(self) -> Result<String<'js>, Value<'js>>
Try convert into String
returning self if the conversion fails.
sourcepub fn from_string(value: String<'js>) -> Self
pub fn from_string(value: String<'js>) -> Self
Convert from String
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_symbol(&self) -> &Symbol<'js>
pub unsafe fn ref_symbol(&self) -> &Symbol<'js>
sourcepub fn into_symbol(self) -> Option<Symbol<'js>>
pub fn into_symbol(self) -> Option<Symbol<'js>>
Try convert into Symbol
sourcepub fn try_into_symbol(self) -> Result<Symbol<'js>, Value<'js>>
pub fn try_into_symbol(self) -> Result<Symbol<'js>, Value<'js>>
Try convert into Symbol
returning self if the conversion fails.
sourcepub fn from_symbol(value: Symbol<'js>) -> Self
pub fn from_symbol(value: Symbol<'js>) -> Self
Convert from Symbol
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_object(&self) -> &Object<'js>
pub unsafe fn ref_object(&self) -> &Object<'js>
sourcepub fn into_object(self) -> Option<Object<'js>>
pub fn into_object(self) -> Option<Object<'js>>
Try convert into Object
sourcepub fn try_into_object(self) -> Result<Object<'js>, Value<'js>>
pub fn try_into_object(self) -> Result<Object<'js>, Value<'js>>
Try convert into Object
returning self if the conversion fails.
sourcepub fn from_object(value: Object<'js>) -> Self
pub fn from_object(value: Object<'js>) -> Self
Convert from Object
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_function(&self) -> &Function<'js>
pub unsafe fn ref_function(&self) -> &Function<'js>
sourcepub fn as_function(&self) -> Option<&Function<'js>>
pub fn as_function(&self) -> Option<&Function<'js>>
Try reinterpret as Function
sourcepub fn into_function(self) -> Option<Function<'js>>
pub fn into_function(self) -> Option<Function<'js>>
Try convert into Function
sourcepub fn try_into_function(self) -> Result<Function<'js>, Value<'js>>
pub fn try_into_function(self) -> Result<Function<'js>, Value<'js>>
Try convert into Function
returning self if the conversion fails.
sourcepub fn from_function(value: Function<'js>) -> Self
pub fn from_function(value: Function<'js>) -> Self
Convert from Function
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_constructor(&self) -> &Constructor<'js>
pub unsafe fn ref_constructor(&self) -> &Constructor<'js>
Interpret as Constructor
§Safety
You should be sure that the value already is of required type before to do it.
sourcepub fn as_constructor(&self) -> Option<&Constructor<'js>>
pub fn as_constructor(&self) -> Option<&Constructor<'js>>
Try reinterpret as Constructor
sourcepub fn into_constructor(self) -> Option<Constructor<'js>>
pub fn into_constructor(self) -> Option<Constructor<'js>>
Try convert into Constructor
sourcepub fn try_into_constructor(self) -> Result<Constructor<'js>, Value<'js>>
pub fn try_into_constructor(self) -> Result<Constructor<'js>, Value<'js>>
Try convert into Constructor
returning self if the conversion fails.
sourcepub fn from_constructor(value: Constructor<'js>) -> Self
pub fn from_constructor(value: Constructor<'js>) -> Self
Convert from Constructor
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_promise(&self) -> &Promise<'js>
pub unsafe fn ref_promise(&self) -> &Promise<'js>
sourcepub fn as_promise(&self) -> Option<&Promise<'js>>
pub fn as_promise(&self) -> Option<&Promise<'js>>
Try reinterpret as Promise
sourcepub fn into_promise(self) -> Option<Promise<'js>>
pub fn into_promise(self) -> Option<Promise<'js>>
Try convert into Promise
sourcepub fn try_into_promise(self) -> Result<Promise<'js>, Value<'js>>
pub fn try_into_promise(self) -> Result<Promise<'js>, Value<'js>>
Try convert into Promise
returning self if the conversion fails.
sourcepub fn from_promise(value: Promise<'js>) -> Self
pub fn from_promise(value: Promise<'js>) -> Self
Convert from Promise
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub fn into_array(self) -> Option<Array<'js>>
pub fn into_array(self) -> Option<Array<'js>>
Try convert into Array
sourcepub fn try_into_array(self) -> Result<Array<'js>, Value<'js>>
pub fn try_into_array(self) -> Result<Array<'js>, Value<'js>>
Try convert into Array
returning self if the conversion fails.
sourcepub fn from_array(value: Array<'js>) -> Self
pub fn from_array(value: Array<'js>) -> Self
Convert from Array
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_exception(&self) -> &Exception<'js>
pub unsafe fn ref_exception(&self) -> &Exception<'js>
sourcepub fn as_exception(&self) -> Option<&Exception<'js>>
pub fn as_exception(&self) -> Option<&Exception<'js>>
Try reinterpret as Exception
sourcepub fn into_exception(self) -> Option<Exception<'js>>
pub fn into_exception(self) -> Option<Exception<'js>>
Try convert into Exception
sourcepub fn try_into_exception(self) -> Result<Exception<'js>, Value<'js>>
pub fn try_into_exception(self) -> Result<Exception<'js>, Value<'js>>
Try convert into Exception
returning self if the conversion fails.
sourcepub fn from_exception(value: Exception<'js>) -> Self
pub fn from_exception(value: Exception<'js>) -> Self
Convert from Exception
source§impl<'js> Value<'js>
impl<'js> Value<'js>
sourcepub unsafe fn ref_big_int(&self) -> &BigInt<'js>
pub unsafe fn ref_big_int(&self) -> &BigInt<'js>
sourcepub fn as_big_int(&self) -> Option<&BigInt<'js>>
pub fn as_big_int(&self) -> Option<&BigInt<'js>>
Try reinterpret as BigInt
sourcepub fn into_big_int(self) -> Option<BigInt<'js>>
pub fn into_big_int(self) -> Option<BigInt<'js>>
Try convert into BigInt
sourcepub fn try_into_big_int(self) -> Result<BigInt<'js>, Value<'js>>
pub fn try_into_big_int(self) -> Result<BigInt<'js>, Value<'js>>
Try convert into BigInt
returning self if the conversion fails.
sourcepub fn from_big_int(value: BigInt<'js>) -> Self
pub fn from_big_int(value: BigInt<'js>) -> Self
Convert from BigInt
Trait Implementations§
source§impl<'js> AsRef<Value<'js>> for ArrayBuffer<'js>
impl<'js> AsRef<Value<'js>> for ArrayBuffer<'js>
source§impl<'js> AsRef<Value<'js>> for Constructor<'js>
impl<'js> AsRef<Value<'js>> for Constructor<'js>
source§impl<'js, T> AsRef<Value<'js>> for TypedArray<'js, T>
impl<'js, T> AsRef<Value<'js>> for TypedArray<'js, T>
source§impl<'js> From<Constructor<'js>> for Value<'js>
impl<'js> From<Constructor<'js>> for Value<'js>
source§fn from(value: Constructor<'js>) -> Self
fn from(value: Constructor<'js>) -> Self
source§impl<'js> PartialEq for Value<'js>
impl<'js> PartialEq for Value<'js>
impl<'js> Eq for Value<'js>
Auto Trait Implementations§
impl<'js> Freeze for Value<'js>
impl<'js> RefUnwindSafe for Value<'js>
impl<'js> !Send for Value<'js>
impl<'js> !Sync for Value<'js>
impl<'js> Unpin for Value<'js>
impl<'js> !UnwindSafe for Value<'js>
Blanket Implementations§
source§impl<'js, T> AsProperty<'js, T> for Twhere
T: IntoJs<'js>,
impl<'js, T> AsProperty<'js, T> for Twhere
T: IntoJs<'js>,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<'js, T> FromParam<'js> for Twhere
T: FromJs<'js>,
impl<'js, T> FromParam<'js> for Twhere
T: FromJs<'js>,
source§fn param_requirement() -> ParamRequirement
fn param_requirement() -> ParamRequirement
source§fn from_param<'a>(params: &mut ParamsAccessor<'a, 'js>) -> Result<T, Error>
fn from_param<'a>(params: &mut ParamsAccessor<'a, 'js>) -> Result<T, Error>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more