Skip to main content

sql_fun_sqlast/sem/names/
schema.rs

1use std::fmt::Display;
2
3/// part of name specifies schema
4#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
5#[serde(transparent)]
6pub struct SchemaName(String);
7
8impl SchemaName {
9    /// create from string
10    #[must_use]
11    pub fn from(value: &str) -> Self {
12        Self(value.to_string())
13    }
14
15    /// convert to string
16    #[must_use]
17    pub fn as_str(&self) -> &str {
18        &self.0
19    }
20
21    /// test schema is `pg_catalog`
22    #[must_use]
23    pub fn is_pg_catalog(&self) -> bool {
24        &self.0 == "pg_catalog"
25    }
26}
27
28impl Display for SchemaName {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        write!(f, "{}", self.0)
31    }
32}