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