use crate::dataset::{MissingLiteral, TaggedMissing};
use std::borrow::Cow;
use time::{Duration, OffsetDateTime};
#[derive(Debug, Clone, PartialEq)]
pub enum CellValue<'a> {
Float(f64),
Int32(i32),
Int64(i64),
NumericString(Cow<'a, str>),
Str(Cow<'a, str>),
Bytes(Cow<'a, [u8]>),
DateTime(OffsetDateTime),
Date(OffsetDateTime),
Time(Duration),
Missing(MissingValue),
}
impl CellValue<'_> {
#[must_use]
pub fn into_owned(self) -> CellValue<'static> {
match self {
CellValue::Float(v) => CellValue::Float(v),
CellValue::Int32(v) => CellValue::Int32(v),
CellValue::Int64(v) => CellValue::Int64(v),
CellValue::NumericString(s) => CellValue::NumericString(Cow::Owned(s.into_owned())),
CellValue::Str(s) => CellValue::Str(Cow::Owned(s.into_owned())),
CellValue::Bytes(bytes) => CellValue::Bytes(Cow::Owned(bytes.into_owned())),
CellValue::DateTime(dt) => CellValue::DateTime(dt),
CellValue::Date(dt) => CellValue::Date(dt),
CellValue::Time(duration) => CellValue::Time(duration),
CellValue::Missing(missing) => CellValue::Missing(missing),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum MissingValue {
System,
Tagged(TaggedMissing),
Range {
lower: MissingLiteral,
upper: MissingLiteral,
},
}
impl MissingValue {
#[must_use]
pub const fn system() -> Self {
Self::System
}
}