polars_config/
resolve_mode.rs1use std::fmt;
2use std::str::FromStr;
3
4#[repr(u8)]
5#[derive(Clone, Debug, Copy, Default, Eq, PartialEq, Hash)]
6pub enum ResolveMode {
7 #[default]
8 None = 0,
9 RowCounts = 1,
10 Full = 2,
11}
12
13impl fmt::Display for ResolveMode {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 write!(f, "{}", self.as_static_str())
16 }
17}
18
19impl FromStr for ResolveMode {
20 type Err = String;
21
22 fn from_str(s: &str) -> Result<Self, Self::Err> {
23 match s {
24 "none" => Ok(Self::None),
25 "row_counts" => Ok(Self::RowCounts),
26 "full" => Ok(Self::Full),
27 v => Err(format!(
28 "`resolve_metadata_level` must be one of {{'none', 'row_counts', 'full'}}, got {v}",
29 )),
30 }
31 }
32}
33
34impl ResolveMode {
35 pub(crate) fn from_discriminant(d: u8) -> Self {
36 match d {
37 0 => Self::None,
38 1 => Self::RowCounts,
39 2 => Self::Full,
40 _ => unreachable!(),
41 }
42 }
43
44 pub fn as_static_str(&self) -> &'static str {
45 match self {
46 Self::None => "none",
47 Self::RowCounts => "row_counts",
48 Self::Full => "full",
49 }
50 }
51}