use super::{Ident, NationalStyle, Text};
#[derive(Debug)]
pub enum Value<'s> {
Null,
Integer(&'s str),
Float(&'s str),
Text(Text<'s>, NationalStyle),
Placeholder(Option<Ident<'s>>),
}
impl<'s> std::fmt::Display for Value<'s> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
crate::fmt::Display::fmt(self, f)
}
}
impl<'s> crate::fmt::Display for Value<'s> {
fn fmt(&self, f: &mut impl crate::fmt::Formatter) -> std::fmt::Result {
match self {
Value::Null => f.write_str("NULL"),
Value::Integer(n) => f.write_str(n),
Value::Float(n) => f.write_str(n),
Value::Text(text, national_style) => {
match national_style {
NationalStyle::None => {}
NationalStyle::National => f.write_char('N')?,
}
crate::fmt::Display::fmt(text, f)
}
Value::Placeholder(ident) => match ident {
Some(ident) => {
f.write_char(':')?;
crate::fmt::Display::fmt(ident, f)
}
None => f.write_char('?'),
},
}
}
}