Skip to main content

wp_model_core/model/
format.rs

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