natter/src/context/plain_list_item.rs

43 lines
1013 B
Rust

use serde::Serialize;
use super::render_context::RenderContext;
use crate::error::CustomError;
use crate::intermediate::IPlainListItem;
use super::macros::render;
use super::RenderElement;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "plain_list_item")]
pub(crate) struct RenderPlainListItem {
tag: Vec<RenderObject>,
children: Vec<RenderElement>,
}
render!(
RenderPlainListItem,
IPlainListItem,
original,
render_context,
{
let tag = {
let mut ret = Vec::new();
for obj in original.tag.iter() {
ret.push(RenderObject::new(render_context.clone(), obj)?);
}
ret
};
let children = {
let mut ret = Vec::new();
for obj in original.children.iter() {
ret.push(RenderElement::new(render_context.clone(), obj)?);
}
ret
};
Ok(RenderPlainListItem { tag, children })
}
);