1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::Zipper;

use psl::schema_ast::ast;

pub type InternalEnum = Zipper<ast::EnumId>;
pub type InternalEnumValue = Zipper<ast::EnumValueId>;

impl InternalEnum {
    pub fn name(&self) -> &str {
        self.dm.walk(self.id).name()
    }

    pub fn db_name(&self) -> &str {
        self.dm.walk(self.id).database_name()
    }

    pub fn schema_name(&self) -> Option<&str> {
        self.dm.walk(self.id).schema().map(|tuple| tuple.0)
    }
}

impl std::fmt::Debug for InternalEnum {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_tuple("InternalEnum").field(&self.name()).finish()
    }
}