pub enum JsValue {
Undefined,
Null,
Bool(bool),
Number(f64),
String(String),
BigInt(JsBigInt),
Array(Rc<RefCell<Vec<JsValue>>>),
Object(Rc<RefCell<BTreeMap<String, JsValue>>>),
Function(ClosureHandle),
Symbol(SymbolId),
Promise(JsPromise<JsValue>),
}Expand description
Tagged union representing dynamic JavaScript values with authentic ECMAScript reference semantics.
Variants§
Undefined
Null
Bool(bool)
Number(f64)
String(String)
BigInt(JsBigInt)
Array(Rc<RefCell<Vec<JsValue>>>)
Object(Rc<RefCell<BTreeMap<String, JsValue>>>)
Function(ClosureHandle)
Symbol(SymbolId)
Promise(JsPromise<JsValue>)
Implementations§
Source§impl JsValue
impl JsValue
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
Serializes this JsValue into a standard JSON string.
Sourcepub fn try_to_json_string(&self) -> Result<String, String>
pub fn try_to_json_string(&self) -> Result<String, String>
Serializes this JsValue into a standard JSON string, returning an error if a cycle is detected.
Sourcepub fn strict_eq(&self, other: &JsValue) -> bool
pub fn strict_eq(&self, other: &JsValue) -> bool
Strict equality comparison (===) adhering to ECMAScript standard.
Sourcepub fn loose_eq(&self, other: &JsValue) -> bool
pub fn loose_eq(&self, other: &JsValue) -> bool
Abstract loose equality comparison (==) adhering to ECMAScript standard.
pub fn is_null(&self) -> bool
pub fn is_undefined(&self) -> bool
pub fn is_truthy(&self) -> bool
pub fn is_function(&self) -> bool
pub fn is_symbol(&self) -> bool
pub fn is_promise(&self) -> bool
pub fn as_promise(&self) -> Option<&JsPromise<JsValue>>
pub fn new_promise(p: JsPromise<JsValue>) -> JsValue
pub fn new_object(map: BTreeMap<String, JsValue>) -> JsValue
pub fn new_array(items: Vec<JsValue>) -> JsValue
pub fn empty_object() -> JsValue
pub fn empty_array() -> JsValue
pub fn has_prop(&self, key: &str) -> bool
pub fn get_prop(&self, key: &str) -> Option<JsValue>
pub fn set_prop(&self, key: impl Into<String>, val: impl Into<JsValue>) -> bool
pub fn get_property(&self, key: &str) -> Option<JsValue>
pub fn set_property( &self, key: impl Into<String>, val: impl Into<JsValue>, ) -> bool
pub fn as_closure_handle(&self) -> Option<&ClosureHandle>
pub fn as_symbol(&self) -> Option<&SymbolId>
pub fn as_f64(&self) -> Option<f64>
pub fn as_str(&self) -> Option<&str>
pub fn as_bool(&self) -> Option<bool>
pub fn as_bigint(&self) -> Option<&JsBigInt>
pub fn remove_property(&mut self, key: &str) -> Option<JsValue>
pub fn get_index(&self, index: usize) -> Option<JsValue>
pub fn set_index(&mut self, index: usize, val: impl Into<JsValue>)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn map<F>(&self, f: F) -> JsValue
pub fn filter<F>(&self, f: F) -> JsValue
pub fn reduce<F>(&self, f: F, initial: JsValue) -> JsValue
pub fn find<F>(&self, f: F) -> Option<JsValue>
pub fn find_index<F>(&self, f: F) -> Option<usize>
pub fn some<F>(&self, f: F) -> bool
pub fn every<F>(&self, f: F) -> bool
pub fn includes(&self, item: &JsValue) -> bool
pub fn slice(&self, start: isize, end: Option<isize>) -> JsValue
pub fn join(&self, separator: &str) -> String
pub fn push(&mut self, val: impl Into<JsValue>)
pub fn pop(&mut self) -> Option<JsValue>
pub fn concat(&self, other: &JsValue) -> JsValue
pub fn reverse(&mut self)
pub fn sort_by<F>(&mut self, f: F)
pub fn flat(&self, depth: usize) -> JsValue
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for JsValue
impl !Send for JsValue
impl !Sync for JsValue
impl !UnwindSafe for JsValue
impl Forget for JsValue
impl Freeze for JsValue
impl Move for JsValue
impl Unpin for JsValue
impl UnsafeUnpin 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