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_exception(&self) -> bool
pub fn is_exception(&self) -> bool
Check if the value is a constructor function
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 referece 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
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 returning self if the conversion fails
sourcepub fn from_string(value: String<'js>) -> Self
pub fn from_string(value: String<'js>) -> Self
Convert from
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
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 returning self if the conversion fails
sourcepub fn from_symbol(value: Symbol<'js>) -> Self
pub fn from_symbol(value: Symbol<'js>) -> Self
Convert from
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
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 returning self if the conversion fails
sourcepub fn from_object(value: Object<'js>) -> Self
pub fn from_object(value: Object<'js>) -> Self
Convert from
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 reinterprete as
sourcepub fn into_function(self) -> Option<Function<'js>>
pub fn into_function(self) -> Option<Function<'js>>
Try convert into
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 returning self if the conversion fails
sourcepub fn from_function(value: Function<'js>) -> Self
pub fn from_function(value: Function<'js>) -> Self
Convert from
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>
sourcepub fn as_constructor(&self) -> Option<&Constructor<'js>>
pub fn as_constructor(&self) -> Option<&Constructor<'js>>
Try reinterprete as
sourcepub fn into_constructor(self) -> Option<Constructor<'js>>
pub fn into_constructor(self) -> Option<Constructor<'js>>
Try convert into
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 returning self if the conversion fails
sourcepub fn from_constructor(value: Constructor<'js>) -> Self
pub fn from_constructor(value: Constructor<'js>) -> Self
Convert from
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
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 returning self if the conversion fails
sourcepub fn from_array(value: Array<'js>) -> Self
pub fn from_array(value: Array<'js>) -> Self
Convert from
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 reinterprete as
sourcepub fn into_exception(self) -> Option<Exception<'js>>
pub fn into_exception(self) -> Option<Exception<'js>>
Try convert into
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 returning self if the conversion fails
sourcepub fn from_exception(value: Exception<'js>) -> Self
pub fn from_exception(value: Exception<'js>) -> Self
Convert from
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 reinterprete as
sourcepub fn into_big_int(self) -> Option<BigInt<'js>>
pub fn into_big_int(self) -> Option<BigInt<'js>>
Try convert into
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 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