1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//! For writing the in-memory representation to SVG.
pub use crate;
use crate::;
use ;
// pub(crate) trait SvgWritable<'a, 'b> {
// /// Convert the in-memory representation of a Fibroblast to SVG. `writer` determines
// /// where the output goes -- a `String`, to a file, etc.
// fn to_svg(
// &'b self,
// context: &DecodingContext<'a>,
// writer: &mut XmlWriter<impl std::io::Write>,
// ) -> ClgnDecodingResult<()>;
// fn to_svg_string(&'b self, context: &DecodingContext<'a>) -> ClgnDecodingResult<String> {
// let mut writer = XmlWriter::new(Cursor::new(Vec::new()));
// self.to_svg(context, &mut writer)?;
// let buf = writer.into_inner().into_inner();
// let out_string = std::str::from_utf8(&buf)?.to_owned();
// Ok(out_string)
// }
// }
// impl<'a, 'b> SvgWritable<'a, 'b> for SvgElement<'a, 'b> {
// fn to_svg(
// &'b self,
// context: &DecodingContext<'a>,
// writer: &mut XmlWriter<impl std::io::Write>,
// ) -> ClgnDecodingResult<()> {
// let Self {
// name,
// attrs,
// children,
// } = self;
// let name = *name;
// // Open the tag (write e.g., `<rect`)
// let mut curr_elem = BytesStart::new(name);
// // Write e.g., `attr1="val1"`
// for (k, v) in &attrs.0 {
// if let Some(v) = v.to_maybe_string() {
// curr_elem.push_attribute((*k, v.as_ref()));
// }
// }
// // Finish tag, writing `>`
// writer.write_event(XmlEvent::Start(curr_elem))?;
// // Write the children
// for child in children.as_ref() {
// child.to_svg(context, writer)?;
// }
// // Close the tag (`</rect>`)
// writer.write_event(XmlEvent::End(BytesEnd::new(name)))?;
// Ok(())
// }
// }
// impl<'a, 'b> SvgWritable<'a, 'b> for NodeGenerator<'a, 'b> {
// fn to_svg(
// &'b self,
// context: &DecodingContext<'a>,
// writer: &mut XmlWriter<impl std::io::Write>,
// ) -> ClgnDecodingResult<()> {
// let Self { children } = self;
// for child in children.as_ref() {
// child.to_svg(context, writer)?;
// }
// Ok(())
// }
// }
// impl<'a, 'b> SvgWritable<'a, 'b> for TextNode<'a, 'b> {
// fn to_svg(
// &self,
// context: &DecodingContext<'a>,
// writer: &mut XmlWriter<impl std::io::Write>,
// ) -> ClgnDecodingResult<()> {
// let Self {
// text,
// is_preescaped,
// ..
// } = self;
// let text = context.eval_exprs_in_str(text.as_ref())?;
// writer.write_event(XmlEvent::Text(if *is_preescaped {
// BytesText::from_escaped(text)
// } else {
// BytesText::new(text.as_ref())
// }))?;
// Ok(())
// }
// }
// impl<'a, 'b> SvgWritable<'a, 'b> for AnyChildTag<'a> {
// fn to_svg(
// &'b self,
// context: &DecodingContext<'a>,
// writer: &mut XmlWriter<impl std::io::Write>,
// ) -> ClgnDecodingResult<()> {
// if let AnyChildTag::Container(container) = self {
// let fb = container.as_fibroblast(context)?;
// return context.with_new_root(fb.context.get_root().clone(), || {
// let children = container.children(context)?;
// for child in &*children {
// child.to_svg(context, writer)?;
// }
// Ok(())
// });
// }
// let vars = self.vars(context)?;
// let node = self.as_node(context)?;
// context.with_new_vars(vars, || match node {
// Node::Element(e) => e.to_svg(context, writer),
// Node::Generator(g) => g.to_svg(context, writer),
// Node::Text(t) => t.to_svg(context, writer),
// })?;
// Ok(())
// }
// }
// impl<'a, 'b> SvgWritable<'a, 'b> for RootTag<'a> {
// fn to_svg(
// &'b self,
// context: &DecodingContext<'a>,
// writer: &mut XmlWriter<impl std::io::Write>,
// ) -> ClgnDecodingResult<()> {
// let elem = self.as_svg_elem(context)?;
// elem.to_svg(context, writer)
// }
// }
// impl<'a> Fibroblast<'a> {
// pub fn to_svg(&'a self, writer: &mut XmlWriter<impl std::io::Write>) -> ClgnDecodingResult<()> {
// self.root.to_svg(&self.context, writer)
// }
// }
pub
pub
pub