pub enum JsValue {
String(String),
Number(String),
Bool(bool),
Null,
Undefined,
Array(Vec<JsValue>),
Object(IndexMap<String, JsValue>),
Expression(String),
}Expand description
A JavaScript value read from source text.
Variants§
String(String)
Number(String)
A number as written.
Bool(bool)
Null
Undefined
Array(Vec<JsValue>)
Object(IndexMap<String, JsValue>)
Expression(String)
Anything that is only known by running the code (a + b, vars.x, `${x}`), as written.
Implementations§
Source§impl JsValue
impl JsValue
pub fn as_str(&self) -> Option<&str>
pub fn as_bool(&self) -> Option<bool>
pub fn as_array(&self) -> Option<&[JsValue]>
pub fn as_object(&self) -> Option<&IndexMap<String, JsValue>>
Sourcepub fn is_computed(&self) -> bool
pub fn is_computed(&self) -> bool
Whether the value, or anything inside it, is computed.
Sourcepub fn string_list(&self) -> Option<Vec<String>>
pub fn string_list(&self) -> Option<Vec<String>>
A string, or every string of an array of strings; None for anything else.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JsValue
impl<'de> Deserialize<'de> for JsValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for JsValue
impl StructuralPartialEq for JsValue
Auto Trait Implementations§
impl Forget for JsValue
impl Freeze for JsValuewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<JsValue>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, JsValue>>: Freeze,
impl Move for JsValue
impl RefUnwindSafe for JsValue
impl Send for JsValue
impl Sync for JsValue
impl Unpin for JsValue
impl UnsafeUnpin for JsValuewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<JsValue>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, JsValue>>: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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
Compare self to
key and return true if they are equal.