pub enum JsValue {
Array(Vec<JsValue>),
Boolean(bool),
Null,
Number(BigFloat),
Object(HashMap<String, JsValue>),
String(String),
Undefined,
Other(String),
}
Expand description
A JavaScript value.
Variants§
Array(Vec<JsValue>)
Boolean(bool)
Null
Number(BigFloat)
Object(HashMap<String, JsValue>)
String(String)
Undefined
Other(String)
When a javascript value is returned that does not fit any of the other
value types in this enum, JsValue::Other
is returned with a string
representation of the value. For example, functions get returned as an
instance of JsValue::Other
.
Implementations§
Source§impl JsValue
impl JsValue
Sourcepub fn from_json(string: &str) -> Self
pub fn from_json(string: &str) -> Self
Parses the given JSON string into a JsValue
. If parsing failed, the
string is returned as a JsValue::Other
.
pub fn from_string(string: &str) -> Self
Sourcepub fn to_string_unenclosed(&self) -> Cow<'_, str>
pub fn to_string_unenclosed(&self) -> Cow<'_, str>
Gets the string of the JsValue::String
, or otherwise just a normal
string representation of the value.
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