1use crate::r#type::Type;
2
3#[derive(Debug, Clone)]
5pub struct Field {
6 pub name: String,
8
9 pub ty: Type,
11
12 pub documentation: String,
14
15 pub annotation: Vec<String>,
17
18 pub value: String,
20
21 pub visibility: Option<String>,
23}
24
25impl Field {
26 pub fn new<T>(name: &str, ty: T) -> Self
28 where
29 T: Into<Type>,
30 {
31 Field {
32 name: name.into(),
33 ty: ty.into(),
34 documentation: String::new(),
35 annotation: Vec::new(),
36 value: String::new(),
37 visibility: None,
38 }
39 }
40
41 pub fn doc(&mut self, documentation: impl Into<String>) -> &mut Self {
43 self.documentation = documentation.into();
44 self
45 }
46
47 pub fn annotation(&mut self, annotation: impl Into<String>) -> &mut Self {
49 self.annotation.push(annotation.into());
50 self
51 }
52
53 pub fn vis(&mut self, visibility: impl Into<String>) -> &mut Self {
55 self.visibility = Some(visibility.into());
56 self
57 }
58}