organic/src/wasm/drawer.rs
Tom Alexander 0aa3939a75
Format.
2024-01-01 18:34:10 -05:00

52 lines
1.3 KiB
Rust

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::types::Drawer;
use crate::types::GetAffiliatedKeywords;
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmDrawer {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
#[serde(rename = "drawer-name")]
pub(crate) drawer_name: String,
}
to_wasm!(
WasmDrawer,
Drawer<'s>,
original,
wasm_context,
{ WasmAstNode::Drawer(original) },
{ "drawer".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::<WasmAstNode>::into)
})
.collect::<Result<Vec<_>, _>>()?;
Ok((
children,
WasmDrawer {
additional_properties,
drawer_name: original.drawer_name.to_owned(),
},
))
}
);