use std::collections::BTreeSet; use serde::Deserialize; use serde::Serialize; use super::ast_node::WasmAstNode; use super::macros::to_wasm; use super::to_wasm::ToWasm; use super::AdditionalProperties; use crate::compare::ElispFact; use crate::types::GetAffiliatedKeywords; use crate::types::Table; use crate::wasm::to_wasm::ToWasmStandardProperties; #[derive(Debug, Serialize, Deserialize)] pub struct WasmTable { #[serde(flatten)] pub(crate) additional_properties: AdditionalProperties, #[serde(rename = "tblfm")] pub(crate) formulas: Option, #[serde(rename = "type")] pub(crate) table_type: String, pub(crate) value: Option, // Always None } #[derive(Debug, Serialize, Deserialize)] #[serde(tag = "string-set")] #[serde(rename = "string-set")] struct WasmStringSet { value: BTreeSet, } to_wasm!( WasmTable, Table<'s>, original, wasm_context, { WasmAstNode::Table(original) }, { "table".into() }, { let additional_properties = original .get_affiliated_keywords() .to_wasm(wasm_context.clone())?; let children = original .children .iter() .map(|child| { child .to_wasm(wasm_context.clone()) .map(Into::::into) }) .collect::, _>>()?; Ok(( children, WasmTable { additional_properties, formulas: if original.formulas.is_empty() { None } else { Some(WasmStringSet { value: original .formulas .iter() .map(|kw| kw.value.to_owned()) .collect(), }) }, table_type: "org".to_owned(), value: None, }, )) } );