vortex_array/operator/
display.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use std::fmt;
5use std::fmt::{Display, Formatter};
6
7use crate::operator::Operator;
8
9impl dyn Operator + '_ {
10    pub fn display_tree(&self) -> impl Display {
11        self
12    }
13}
14
15pub enum DisplayFormat {
16    Compact,
17    Tree,
18}
19
20impl Display for dyn Operator + '_ {
21    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
22        write!(f, "{}", self.fmt_all())
23    }
24}
25
26pub struct TreeNodeDisplay<'a, T: Operator + ?Sized>(pub &'a T);
27
28impl<'a, T: Operator + ?Sized> Display for TreeNodeDisplay<'a, T> {
29    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
30        self.0.fmt_as(DisplayFormat::Tree, f)
31    }
32}