wp_model_core/model/
format.rs1use std::fmt::Formatter;
2
3pub struct MetaFmt<T>(pub T);
4
5pub struct FunFmt<T>(pub T);
6pub struct KVFmt<T>(pub T);
7
8pub struct CSVFmt<T>(pub T);
9
10#[derive(Debug)]
12pub struct NormalFmt<T>(pub T);
13#[derive(Debug)]
14pub struct RawFmt<T>(pub T);
15
16pub struct JsonFmt<T>(pub T);
17
18pub struct SqlFmt<T>(pub T);
19
20pub struct ProtoFmt<T>(pub T);
21
22pub trait LevelFormatAble {
23 fn level_fmt(&self, f: &mut Formatter<'_>, level: usize) -> std::fmt::Result;
24}
25
26impl std::fmt::Display for MetaFmt<&crate::model::DataRecord> {
27 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
28 use crate::model::DataType;
29 write!(f, "\nline:\n(")?;
30 for o in self.0.items.iter() {
31 if *o.get_meta() != DataType::Ignore {
32 write!(f, "{},", String::from(o.get_meta()))?;
33 }
34 }
35 write!(f, ")")
36 }
37}