A pipeline is a sequence of processing stages in which each stage transforms data for the next stage. The render-hex program uses four stages to turn hexadecimal input into an SVG drawing. section 10.4.2
The render-hex pipeline proceeds through these transformations:
- Receive input from standard input. section 10.4.2
- Parse hexadecimal bytes into operations describing a virtual pen's movement. section 10.4.2
- Convert operations into SVG path commands. section 10.4.2
- Generate and save an SVG file that browsers and graphics packages can display. section 10.4.2
Separating parsing from conversion leaves room for additional transformations. The pipeline is managed directly in main(), where each stage passes its result to the next. section 10.4.2
render-hex main function
The program collects command-line arguments, parses the input, converts the resulting operations, generates an SVG document, and saves it: parse(input) → convert(&operations) → generate_svg(path_data) → svg::save(save_to, &document). section 10.4.2
Listing 10.14 The main() function of render-hex
166 fn main() {
167 let args = env::args().collect::<Vec<String>>(); #1
168 let input = args.get(1).unwrap(); #1
169 let default = format!("{}.svg", input); #1
170 let save_to = args.get(2).unwrap_or(&default); #1
171
172 let operations = parse(input); #2
173 let path_data = convert(&operations); #2
174 let document = generate_svg(path_data); #2
175 svg::save(save_to, &document).unwrap(); #2
176 }
Inspect the complete orchestration point for the four-stage SVG generation pipeline. section 10.4.2















































