pub enum JsonnetValue {
Null,
Boolean(bool),
Number(f64),
String(String),
Array(Vec<JsonnetValue>),
Object(HashMap<String, JsonnetValue>),
Function(JsonnetFunction),
Builtin(JsonnetBuiltin),
}Expand description
Jsonnet value types
Variants§
Null
Null value
Boolean(bool)
Boolean value
Number(f64)
Number value (f64)
String(String)
String value
Array(Vec<JsonnetValue>)
Array value
Object(HashMap<String, JsonnetValue>)
Object value
Function(JsonnetFunction)
Function value
Builtin(JsonnetBuiltin)
Builtin function value
Implementations§
Source§impl JsonnetValue
impl JsonnetValue
Sourcepub fn from_json_value(value: Value) -> Self
pub fn from_json_value(value: Value) -> Self
Convert from serde_json::Value to JsonnetValue
Source§impl JsonnetValue
impl JsonnetValue
Sourcepub fn array(values: Vec<JsonnetValue>) -> Self
pub fn array(values: Vec<JsonnetValue>) -> Self
Create an array value
Sourcepub fn object(fields: HashMap<String, JsonnetValue>) -> Self
pub fn object(fields: HashMap<String, JsonnetValue>) -> Self
Create an object value
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Convert to serde_json::Value for serialization
Sourcepub fn as_boolean(&self) -> Result<bool>
pub fn as_boolean(&self) -> Result<bool>
Try to convert to a boolean
Sourcepub fn as_array(&self) -> Result<&Vec<JsonnetValue>>
pub fn as_array(&self) -> Result<&Vec<JsonnetValue>>
Try to convert to an array
Sourcepub fn get_field(&self, field: &str) -> Result<&JsonnetValue>
pub fn get_field(&self, field: &str) -> Result<&JsonnetValue>
Get a field from an object
Sourcepub fn get_index(&self, index: i64) -> Result<&JsonnetValue>
pub fn get_index(&self, index: i64) -> Result<&JsonnetValue>
Get an element from an array by index
Sourcepub fn equals(&self, other: &JsonnetValue) -> bool
pub fn equals(&self, other: &JsonnetValue) -> bool
Check if two values are equal
pub fn add(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn sub(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn mul(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn div(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn modulo(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn lt(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn le(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn gt(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn ge(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn eq(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn ne(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn and(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn or(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn not(&self) -> Result<JsonnetValue>
pub fn neg(&self) -> Result<JsonnetValue>
Trait Implementations§
Source§impl Clone for JsonnetValue
impl Clone for JsonnetValue
Source§fn clone(&self) -> JsonnetValue
fn clone(&self) -> JsonnetValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JsonnetValue
impl Debug for JsonnetValue
Source§impl Default for JsonnetValue
impl Default for JsonnetValue
Source§fn default() -> JsonnetValue
fn default() -> JsonnetValue
Returns the “default value” for a type. Read more
Source§impl Display for JsonnetValue
impl Display for JsonnetValue
Source§impl PartialEq for JsonnetValue
impl PartialEq for JsonnetValue
impl StructuralPartialEq for JsonnetValue
Auto Trait Implementations§
impl Freeze for JsonnetValue
impl RefUnwindSafe for JsonnetValue
impl Send for JsonnetValue
impl Sync for JsonnetValue
impl Unpin for JsonnetValue
impl UnwindSafe for JsonnetValue
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