use crate::errors::PgDbError;
use std::{
fmt::{Display, Formatter},
str::FromStr,
};
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
pub enum DdlDialect {
#[default]
Cypher,
Gql,
}
impl Display for DdlDialect {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
DdlDialect::Cypher => write!(f, "cypher"),
DdlDialect::Gql => write!(f, "gql"),
}
}
}
impl FromStr for DdlDialect {
type Err = PgDbError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"cypher" => Ok(DdlDialect::Cypher),
"gql" => Ok(DdlDialect::Gql),
other => Err(PgDbError::UnsupportedDialect {
dialect: other.to_string(),
}),
}
}
}