Skip to main content

datarust_profile/
types.rs

1//! Shared value types used across the profiling modules.
2
3use std::fmt;
4
5/// The inferred semantic type of a single column.
6///
7/// Type inference is heuristic: a column is `Numeric` when *all* non-empty
8/// values parse as `f64`, and `Categorical` otherwise (or when the caller
9/// declares it as such by profiling a [`datarust::StrMatrix`]).
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize))]
12pub enum ColumnType {
13    /// Continuous-valued numeric column.
14    Numeric,
15    /// Discrete string/category column.
16    Categorical,
17}
18
19impl fmt::Display for ColumnType {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        match self {
22            ColumnType::Numeric => f.write_str("numeric"),
23            ColumnType::Categorical => f.write_str("categorical"),
24        }
25    }
26}
27
28/// A severity level attached to a [`crate::quality::QualityIssue`].
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30#[cfg_attr(feature = "serde", derive(serde::Serialize))]
31pub enum Severity {
32    /// Informational; no action required.
33    Info,
34    /// Worth investigating; not necessarily wrong.
35    Warning,
36    /// Likely to bias downstream models or break preprocessing.
37    Critical,
38}
39
40impl fmt::Display for Severity {
41    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42        match self {
43            Severity::Info => f.write_str("info"),
44            Severity::Warning => f.write_str("warning"),
45            Severity::Critical => f.write_str("critical"),
46        }
47    }
48}