about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs9
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)