surrealdb_core/sql/
base.rs1use crate::sql::statements::info::InfoStructure;
2use crate::sql::{Ident, Value};
3use revision::revisioned;
4use serde::{Deserialize, Serialize};
5use std::fmt;
6
7#[revisioned(revision = 1)]
8#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
9#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
10#[non_exhaustive]
11pub enum Base {
12 Root,
13 Ns,
14 Db,
15 Sc(Ident),
17}
18
19impl Default for Base {
20 fn default() -> Self {
21 Self::Root
22 }
23}
24
25impl fmt::Display for Base {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27 match self {
28 Self::Ns => f.write_str("NAMESPACE"),
29 Self::Db => f.write_str("DATABASE"),
30 Self::Sc(sc) => write!(f, "SCOPE {sc}"),
32 Self::Root => f.write_str("ROOT"),
33 }
34 }
35}
36
37impl InfoStructure for Base {
38 fn structure(self) -> Value {
39 self.to_string().into()
40 }
41}