dbml_rs/ast/enums.rs
1use alloc::string::String;
2use alloc::vec::Vec;
3
4use super::*;
5
6/// Represents a top-level block of enum.
7#[derive(Debug, Clone, Default)]
8pub struct EnumBlock {
9 /// The range of the span in the source text.
10 pub span_range: SpanRange,
11 /// The identifier of the enum block including schema (optional) and name.
12 pub ident: EnumIdent,
13 /// The list of variants of the enums.
14 pub values: Vec<EnumValue>,
15}
16
17/// Represents an enum value or variant.
18#[derive(Debug, Clone, Default)]
19pub struct EnumValue {
20 /// The range of the span in the source text.
21 pub span_range: SpanRange,
22 pub value: Ident,
23 pub settings: Option<EnumValueSettings>,
24}
25
26/// Represents settings of an enum value or variant.
27#[derive(Debug, Clone, Default)]
28pub struct EnumValueSettings {
29 /// The range of the span in the source text.
30 pub span_range: SpanRange,
31 /// A vector of key and optional value pairs representing attributes of the enum value.
32 pub attributes: Vec<Attribute>,
33 /// A note associated with the enum value.
34 pub note: Option<String>,
35}
36
37/// Represents an enum identifier including schema (optional) and name.
38#[derive(Debug, Clone, Default)]
39pub struct EnumIdent {
40 /// The range of the span in the source text.
41 pub span_range: SpanRange,
42 /// The schema of the enum.
43 pub schema: Option<Ident>,
44 /// The name of the enum.
45 pub name: Ident,
46}