pub enum JValue {
Null,
Bool(bool),
Number(f64),
String(Rc<str>),
Array(Rc<Vec<JValue>>),
Object(Rc<IndexMap<String, JValue>>),
Undefined,
Lambda {
lambda_id: Rc<str>,
params: Rc<Vec<String>>,
name: Option<Rc<str>>,
signature: Option<Rc<str>>,
},
Builtin {
name: Rc<str>,
},
Regex {
pattern: Rc<str>,
flags: Rc<str>,
},
}Expand description
A JSON-like value with O(1) clone semantics via Rc-wrapping.
Standard JSON types (Array, Object, String) are wrapped in Rc for cheap cloning. Internal types (Undefined, Lambda, Builtin, Regex) are first-class variants instead of tagged objects with hash-map lookups.
Variants§
Null
Bool(bool)
Number(f64)
String(Rc<str>)
Array(Rc<Vec<JValue>>)
Object(Rc<IndexMap<String, JValue>>)
Undefined
Lambda
Builtin
Regex
Implementations§
Source§impl JValue
impl JValue
pub fn is_null(&self) -> bool
pub fn is_undefined(&self) -> bool
pub fn is_bool(&self) -> bool
pub fn is_number(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_array(&self) -> bool
pub fn is_object(&self) -> bool
pub fn is_lambda(&self) -> bool
pub fn is_builtin(&self) -> bool
pub fn is_function(&self) -> bool
pub fn is_regex(&self) -> bool
Source§impl JValue
impl JValue
pub fn as_f64(&self) -> Option<f64>
pub fn as_i64(&self) -> Option<i64>
pub fn as_str(&self) -> Option<&str>
pub fn as_bool(&self) -> Option<bool>
pub fn as_array(&self) -> Option<&Vec<JValue>>
pub fn as_object(&self) -> Option<&IndexMap<String, JValue>>
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<JValue>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<JValue>>
Get a mutable reference to the inner Vec, cloning if shared (Rc::make_mut).
Source§impl JValue
impl JValue
pub fn from_i64(n: i64) -> Self
pub fn from_f64(n: f64) -> Self
pub fn string(s: impl Into<Rc<str>>) -> Self
pub fn array(v: Vec<JValue>) -> Self
pub fn object(m: IndexMap<String, JValue>) -> Self
pub fn lambda( lambda_id: impl Into<Rc<str>>, params: Vec<String>, name: Option<impl Into<Rc<str>>>, signature: Option<impl Into<Rc<str>>>, ) -> Self
pub fn builtin(name: impl Into<Rc<str>>) -> Self
pub fn regex(pattern: impl Into<Rc<str>>, flags: impl Into<Rc<str>>) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for JValue
impl<'de> Deserialize<'de> for JValue
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
Auto Trait Implementations§
impl Freeze for JValue
impl RefUnwindSafe for JValue
impl !Send for JValue
impl !Sync for JValue
impl Unpin for JValue
impl UnsafeUnpin for JValue
impl UnwindSafe for JValue
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