Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add method for yaml writing in wasm #121

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion rust/wasm-binding/src/rpc_rust_defined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Uint8Array, String> {
let chart_file = decode::<quary_proto::ChartFile>(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]
Expand Down
Loading