Debian Codegraph @

src/output.rs

raw symbols SCIP
1 /*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 use std::marker::PhantomData;
9
10 use super::ascii::AsciiRenderer;
11 use super::ascii_large::AsciiLargeRenderer;
12 use super::box_drawing::BoxDrawingRenderer;
13 use super::render::GraphRow;
14 use super::render::Renderer;
15
16 pub(crate) struct OutputRendererOptions {
17 pub(crate) min_row_height: usize,
18 }
19
20 pub struct OutputRendererBuilder<N, R>
21 where
22 R: Renderer<N, Output = GraphRow<N>> + Sized,
23 {
24 inner: R,
25 options: OutputRendererOptions,
26 _phantom: PhantomData<N>,
27 }
28
29 impl<N, R> OutputRendererBuilder<N, R>
30 where
31 R: Renderer<N, Output = GraphRow<N>> + Sized,
32 {
33 pub fn new(inner: R) -> Self {
34 OutputRendererBuilder {
35 inner,
36 options: OutputRendererOptions { min_row_height: 2 },
37 _phantom: PhantomData,
38 }
39 }
40
41 pub fn with_min_row_height(mut self, min_row_height: usize) -> Self {
42 self.options.min_row_height = min_row_height;
43 self
44 }
45
46 pub fn build_ascii(self) -> AsciiRenderer<N, R> {
47 AsciiRenderer::new(self.inner, self.options)
48 }
49
50 pub fn build_ascii_large(self) -> AsciiLargeRenderer<N, R> {
51 AsciiLargeRenderer::new(self.inner, self.options)
52 }
53
54 pub fn build_box_drawing(self) -> BoxDrawingRenderer<N, R> {
55 BoxDrawingRenderer::new(self.inner, self.options)
56 }
57 }