1mod toml;2mod yaml;34use jrsonnet_evaluator::{5 function::builtin,6 manifest::{escape_string_json, JsonFormat},7 IStr, ObjValue, Result, Val,8};9pub use toml::TomlFormat;10pub use yaml::YamlFormat;1112#[builtin]13pub fn builtin_escape_string_json(str_: IStr) -> Result<String> {14 Ok(escape_string_json(&str_))15}1617#[builtin]18pub fn builtin_manifest_json_ex(19 value: Val,20 indent: IStr,21 newline: Option<IStr>,22 key_val_sep: Option<IStr>,23 #[cfg(feature = "exp-preserve-order")] preserve_order: Option<bool>,24) -> Result<String> {25 let newline = newline.as_deref().unwrap_or("\n");26 let key_val_sep = key_val_sep.as_deref().unwrap_or(": ");27 value.manifest(JsonFormat::std_to_json(28 indent.to_string(),29 newline,30 key_val_sep,31 #[cfg(feature = "exp-preserve-order")]32 preserve_order.unwrap_or(false),33 ))34}3536#[builtin]37pub fn builtin_manifest_yaml_doc(38 value: Val,39 indent_array_in_object: Option<bool>,40 quote_keys: Option<bool>,41 #[cfg(feature = "exp-preserve-order")] preserve_order: Option<bool>,42) -> Result<String> {43 value.manifest(YamlFormat::std_to_yaml(44 indent_array_in_object.unwrap_or(false),45 quote_keys.unwrap_or(true),46 #[cfg(feature = "exp-preserve-order")]47 preserve_order.unwrap_or(false),48 ))49}5051#[builtin]52pub fn builtin_manifest_toml_ex(53 value: ObjValue,54 indent: IStr,55 #[cfg(feature = "exp-preserve-order")] preserve_order: Option<bool>,56) -> Result<String> {57 Val::Obj(value).manifest(TomlFormat::std_to_toml(58 indent.to_string(),59 #[cfg(feature = "exp-preserve-order")]60 preserve_order.unwrap_or(false),61 ))62}6364#[builtin]65pub fn builtin_to_string(a: Val) -> Result<IStr> {66 a.to_string()67}