diff options
author | Vincent Ambo <mail@tazj.in> | 2023-01-15T11·52+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-01-16T13·43+0000 |
commit | d365b092262013e074f0fe800a1955032eaa2fd9 (patch) | |
tree | d5c32fecf48fdcc2ec9697accd2be69c1c977a1a /tvix/eval/src/builtins/mod.rs | |
parent | 1786b4c835cbce619ddae77ffeebe89b24d50c0e (diff) |
feat(tvix/eval): implement builtins.toXML r/5664
Change-Id: I009efc53a8e98f0650ae660c4decd8216e8a06e7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7835 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index b93bbd99f87a..7614353f5bbb 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -20,6 +20,7 @@ use crate::{ use self::versions::{VersionPart, VersionPartsIter}; +mod to_xml; mod versions; #[cfg(feature = "impure")] @@ -918,6 +919,14 @@ mod pure_builtins { .map(Value::String) } + #[builtin("toXML")] + fn builtin_to_xml(vm: &mut VM, value: Value) -> Result<Value, ErrorKind> { + value.deep_force(vm, &mut Default::default())?; + let mut buf: Vec<u8> = vec![]; + to_xml::value_to_xml(&mut buf, &value)?; + Ok(String::from_utf8(buf)?.into()) + } + #[builtin("placeholder")] fn builtin_placeholder(vm: &mut VM, #[lazy] _: Value) -> Result<Value, ErrorKind> { // TODO(amjoseph) |