2023-11-18 13:56:13 +00:00
|
|
|
use crate::sql::Ident;
|
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)]
|
2023-08-17 18:03:46 +00:00
|
|
|
#[revisioned(revision = 1)]
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|