1use super::schema::SchemaType;
2
3#[derive(Debug, Clone, PartialEq, Default)]
4pub struct FieldMetadata {
5 pub description: Option<String>,
6 pub default_value: Option<String>,
7 pub is_unique: bool,
8 pub is_readonly: bool,
9}
10
11impl FieldMetadata {
12 pub fn new() -> Self {
13 Self::default()
14 }
15}
16
17#[derive(Debug, Clone, PartialEq)]
18pub struct Field {
19 pub name: String,
20 pub field_type: SchemaType,
21 pub optional: bool,
22 pub metadata: FieldMetadata,
23}
24
25impl Field {
26 pub fn new(name: impl Into<String>, field_type: SchemaType) -> Self {
27 Self {
28 name: name.into(),
29 field_type,
30 optional: false,
31 metadata: FieldMetadata::default(),
32 }
33 }
34
35 pub fn optional(mut self) -> Self {
36 self.optional = true;
37 self
38 }
39
40 pub fn with_metadata(mut self, metadata: FieldMetadata) -> Self {
41 self.metadata = metadata;
42 self
43 }
44}