oca_presentation/page/
recursion_setup.rs1use recursion::{Expandable, MappableFrame, PartiallyApplied};
2
3use super::PageElement;
4
5pub enum PageElementFrame<A> {
6 Value(String),
7 Page {
8 name: String,
9 attribute_order: Vec<A>,
10 },
11}
12
13impl MappableFrame for PageElementFrame<PartiallyApplied> {
14 type Frame<X> = PageElementFrame<X>;
15
16 fn map_frame<A, B>(input: Self::Frame<A>, f: impl FnMut(A) -> B) -> Self::Frame<B> {
17 match input {
18 PageElementFrame::Value(v) => PageElementFrame::Value(v),
19 PageElementFrame::Page {
20 name,
21 attribute_order,
22 } => PageElementFrame::Page {
23 name,
24 attribute_order: attribute_order.into_iter().map(f).collect(),
25 },
26 }
27 }
28}
29
30impl Expandable for PageElement {
31 type FrameToken = PageElementFrame<PartiallyApplied>;
32
33 fn from_frame(val: <Self::FrameToken as MappableFrame>::Frame<Self>) -> Self {
34 match val {
35 PageElementFrame::Value(v) => PageElement::Value(v),
36 PageElementFrame::Page {
37 name,
38 attribute_order,
39 } => PageElement::Page {
40 name,
41 attribute_order,
42 },
43 }
44 }
45}