use std::path::PathBuf; use serde::Serialize; use super::additional_property::AdditionalProperties; use super::additional_property::AdditionalPropertyValue; use super::ast_node::WasmAstNode; use super::macros::new_to_wasm; use super::macros::to_wasm; use super::to_wasm::ToWasm; #[cfg(feature = "wasm_test")] use crate::compare::ElispFact; use crate::types::Document; use crate::wasm::to_wasm::ToWasmStandardProperties; #[derive(Debug, Serialize)] pub struct WasmDocument { #[serde(flatten)] pub(crate) additional_properties: AdditionalProperties, #[serde(rename = "CATEGORY")] pub(crate) category: Option, pub(crate) path: Option, } new_to_wasm!( WasmDocument, Document<'s>, original, wasm_context, { WasmAstNode::Document(original) }, { "org-data".into() }, { let category = original.category.as_ref().map(String::as_str); let path = original.path.clone(); let mut additional_properties = AdditionalProperties::default(); for (name, val) in original.get_additional_properties().map(|node_property| { ( node_property.property_name.to_uppercase(), AdditionalPropertyValue::SingleString(node_property.value.unwrap_or("").to_owned()), ) }) { additional_properties.properties.insert(name, val); } let children = original .zeroth_section .iter() .map(|child| { child .to_wasm(wasm_context.clone()) .map(Into::::into) }) .chain(original.children.iter().map(|child| { child .to_wasm(wasm_context.clone()) .map(Into::::into) })) .collect::, _>>()?; Ok(( children, WasmDocument { additional_properties, category: category.map(str::to_owned), path, }, )) } );