Start defining the return type.

This commit is contained in:
Tom Alexander
2023-12-24 01:35:21 -05:00
parent b3f97dbb40
commit 2d5593681f
6 changed files with 47 additions and 3 deletions

View File

@@ -1,7 +1,17 @@
#![no_main]
use organic::parser::parse_with_settings;
use organic::settings::GlobalSettings;
use wasm::ParseResult;
use wasm_bindgen::prelude::wasm_bindgen;
mod wasm;
#[wasm_bindgen]
pub fn add(left: usize, right: usize) -> usize {
left + right
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
let global_settings = GlobalSettings::default();
let rust_parsed = parse_with_settings(org_contents, &global_settings)
.map(|document| ParseResult::Success(document.into()))
.unwrap_or_else(|err| ParseResult::Error(format!("{:?}", err)));
serde_wasm_bindgen::to_value(&rust_parsed).unwrap()
}