2024-04-16 08:05:07 +00:00
|
|
|
use crate::sql::statements::info::InfoStructure;
|
|
|
|
use crate::sql::{Ident, Value};
|
2023-08-17 18:03:46 +00:00
|
|
|
use revision::revisioned;
|
2020-06-29 15:36:01 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::fmt;
|
|
|
|
|
2023-08-18 22:51:56 +00:00
|
|
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
2024-01-09 15:34:52 +00:00
|
|
|
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
2023-08-17 18:03:46 +00:00
|
|
|
#[revisioned(revision = 1)]
|
2024-04-02 20:12:08 +00:00
|
|
|
#[non_exhaustive]
|
2020-06-29 15:36:01 +00:00
|
|
|
pub enum Base {
|
2023-07-29 18:47:25 +00:00
|
|
|
Root,
|
2020-06-29 15:36:01 +00:00
|
|
|
Ns,
|
|
|
|
Db,
|
2022-09-25 21:56:33 +00:00
|
|
|
Sc(Ident),
|
2020-06-29 15:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Base {
|
2022-10-04 21:51:18 +00:00
|
|
|
fn default() -> Self {
|
2023-07-29 18:47:25 +00:00
|
|
|
Self::Root
|
2020-06-29 15:36:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for Base {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
match self {
|
2022-10-04 21:51:18 +00:00
|
|
|
Self::Ns => f.write_str("NAMESPACE"),
|
|
|
|
Self::Db => f.write_str("DATABASE"),
|
2023-02-03 11:47:07 +00:00
|
|
|
Self::Sc(sc) => write!(f, "SCOPE {sc}"),
|
2023-07-29 18:47:25 +00:00
|
|
|
Self::Root => f.write_str("ROOT"),
|
2020-06-29 15:36:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-04-16 08:05:07 +00:00
|
|
|
impl InfoStructure for Base {
|
|
|
|
fn structure(self) -> Value {
|
|
|
|
self.to_string().into()
|
|
|
|
}
|
|
|
|
}
|