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