surrealpatch/core/src/sql/base.rs

32 lines
662 B
Rust
Raw Normal View History

use crate::sql::Ident;
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))]
#[revisioned(revision = 1)]
2020-06-29 15:36:01 +00:00
pub enum Base {
Root,
2020-06-29 15:36:01 +00:00
Ns,
Db,
Sc(Ident),
2020-06-29 15:36:01 +00:00
}
impl Default for Base {
fn default() -> Self {
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 {
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}"),
Self::Root => f.write_str("ROOT"),
2020-06-29 15:36:01 +00:00
}
}
}