use crate::sql::statements::info::InfoStructure; use crate::sql::{Ident, Value}; use revision::revisioned; use serde::{Deserialize, Serialize}; use std::fmt; #[revisioned(revision = 1)] #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[non_exhaustive] pub enum Base { Root, Ns, Db, Sc(Ident), } impl Default for Base { fn default() -> Self { Self::Root } } impl fmt::Display for Base { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Self::Ns => f.write_str("NAMESPACE"), Self::Db => f.write_str("DATABASE"), Self::Sc(sc) => write!(f, "SCOPE {sc}"), Self::Root => f.write_str("ROOT"), } } } impl InfoStructure for Base { fn structure(self) -> Value { self.to_string().into() } }