diff --git a/rust/wasm-binding/src/rpc_rust_defined.rs b/rust/wasm-binding/src/rpc_rust_defined.rs index 371b1e06..bcfc74eb 100644 --- a/rust/wasm-binding/src/rpc_rust_defined.rs +++ b/rust/wasm-binding/src/rpc_rust_defined.rs @@ -2,7 +2,7 @@ use crate::rpc_helpers::{decode, encode}; use crate::rpc_proto_scaffolding::{database_query_generator_from_config, JsFileSystem}; use crate::uint8_reader::Uint8ArrayReader; use js_sys::{Function, Promise, Uint8Array}; -use quary_core::chart::chart_file_from_yaml; +use quary_core::chart::{chart_file_from_yaml, chart_file_to_yaml}; use quary_core::database_snowflake::validate_snowfalke_account_identifier; use quary_core::test_runner::{ run_model_tests_internal, run_tests_internal, RunStatementFunc, RunTestError, @@ -13,6 +13,15 @@ use std::rc::Rc; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; +/// write chart file to Uint8Array string encodes a chart file in Uint8Array proto and returns it +/// as yaml string. +#[wasm_bindgen] +pub fn write_chart_file(chart_file: Uint8Array) -> Result { + let chart_file = decode::(chart_file)?; + let yaml = chart_file_to_yaml(&chart_file)?; + Ok(Uint8Array::from(yaml.as_bytes())) +} + /// string to chart file parses a chart file in Uint8Array string and returns a Uint8Array chart /// file encoded in proto. #[wasm_bindgen]