Enum jrsonnet_evaluator::val::Val
source · pub enum Val {
Bool(bool),
Null,
Str(StrValue),
Num(f64),
Arr(ArrValue),
Obj(ObjValue),
Func(FuncVal),
}
Expand description
Represents any valid Jsonnet value.
Variants§
Bool(bool)
Represents a Jsonnet boolean.
Null
Represents a Jsonnet null value.
Str(StrValue)
Represents a Jsonnet string.
Num(f64)
Represents a Jsonnet number. Should be finite, and not NaN This restriction isn’t enforced by enum, as enum field can’t be marked as private
Arr(ArrValue)
Represents a Jsonnet array.
Obj(ObjValue)
Represents a Jsonnet object.
Func(FuncVal)
Represents a Jsonnet function.
Implementations§
source§impl Val
impl Val
pub const fn as_bool(&self) -> Option<bool>
pub const fn as_null(&self) -> Option<()>
pub fn as_str(&self) -> Option<IStr>
pub const fn as_num(&self) -> Option<f64>
pub fn as_arr(&self) -> Option<ArrValue>
pub fn as_obj(&self) -> Option<ObjValue>
pub fn as_func(&self) -> Option<FuncVal>
sourcepub fn new_checked_num(num: f64) -> Result<Self>
pub fn new_checked_num(num: f64) -> Result<Self>
Creates Val::Num
after checking for numeric overflow.
As numbers are f64
, we can just check for their finity.
pub const fn value_type(&self) -> ValType
pub fn manifest(&self, format: impl ManifestFormat) -> Result<String>
pub fn to_string(&self) -> Result<IStr>
pub fn into_indexable(self) -> Result<IndexableVal>
Trait Implementations§
source§impl<'de> Deserialize<'de> for Val
impl<'de> Deserialize<'de> for Val
source§fn deserialize<D>(deserializer: D) -> Result<Val, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Val, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<IndexableVal> for Val
impl From<IndexableVal> for Val
source§fn from(v: IndexableVal) -> Self
fn from(v: IndexableVal) -> Self
Converts to this type from the input type.