pub enum JsValue {
Show 13 variants
Undefined,
Null,
Bool(bool),
Int(i32),
Float(f64),
String(String),
Array(Vec<JsValue>),
Object(HashMap<String, JsValue>),
Resource(ResourceValue),
Raw(RawJSValue),
Exception(RawJSValue),
Date(DateTime<Utc>),
BigInt(BigInt),
// some variants omitted
}Expand description
A value that can be (de)serialized to/from the quickjs runtime.
Variants§
Undefined
Null
Bool(bool)
Int(i32)
Float(f64)
String(String)
Array(Vec<JsValue>)
Object(HashMap<String, JsValue>)
Resource(ResourceValue)
Raw(RawJSValue)
Exception(RawJSValue)
Date(DateTime<Utc>)
chrono::Datetimechrono feature.
BigInt(BigInt)
num_bigint::BigInt / JS BigInt integration
Only available with the optional bigint feature
Implementations§
Source§impl JsValue
impl JsValue
pub fn create_object( context: *mut JSContext, map: HashMap<String, JsValue>, ) -> Result<Self, ValueError>
pub fn value_type(&self) -> &'static str
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Cast value to a str.
Returns Some(&str) if value is a JsValue::String, None otherwise.
Sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Convert to String.
pub fn new_resource<T: Any>(value: T) -> Self
pub fn as_resource<T: Any, R, F: FnOnce(&mut T) -> R>( &self, callback: F, ) -> Option<R>
pub fn get_properties(&self) -> Option<HashMap<String, JsValue>>
pub fn call_as_function( &self, args: Vec<JsValue>, ) -> Result<JsValue, ExecutionError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsValue
impl !RefUnwindSafe for JsValue
impl !Send for JsValue
impl !Sync for JsValue
impl Unpin for JsValue
impl !UnwindSafe for JsValue
Blanket Implementations§
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
Mutably borrows from an owned value. Read more