sara_core/edit/
options.rs1use crate::model::TraceabilityLinks;
4
5#[derive(Debug, Clone, Default)]
7pub struct EditOptions {
8 pub item_id: String,
10 pub name: Option<String>,
12 pub description: Option<String>,
14 pub refines: Option<Vec<String>>,
16 pub derives_from: Option<Vec<String>>,
18 pub satisfies: Option<Vec<String>>,
20 pub specification: Option<String>,
22 pub platform: Option<String>,
24}
25
26impl EditOptions {
27 pub fn new(item_id: impl Into<String>) -> Self {
29 Self {
30 item_id: item_id.into(),
31 ..Default::default()
32 }
33 }
34
35 pub fn with_name(mut self, name: impl Into<String>) -> Self {
37 self.name = Some(name.into());
38 self
39 }
40
41 pub fn with_description(mut self, description: impl Into<String>) -> Self {
43 self.description = Some(description.into());
44 self
45 }
46
47 pub fn with_refines(mut self, refines: Vec<String>) -> Self {
49 self.refines = Some(refines);
50 self
51 }
52
53 pub fn with_derives_from(mut self, derives_from: Vec<String>) -> Self {
55 self.derives_from = Some(derives_from);
56 self
57 }
58
59 pub fn with_satisfies(mut self, satisfies: Vec<String>) -> Self {
61 self.satisfies = Some(satisfies);
62 self
63 }
64
65 pub fn with_specification(mut self, specification: impl Into<String>) -> Self {
67 self.specification = Some(specification.into());
68 self
69 }
70
71 pub fn with_platform(mut self, platform: impl Into<String>) -> Self {
73 self.platform = Some(platform.into());
74 self
75 }
76
77 pub fn has_updates(&self) -> bool {
79 self.name.is_some()
80 || self.description.is_some()
81 || self.refines.is_some()
82 || self.derives_from.is_some()
83 || self.satisfies.is_some()
84 || self.specification.is_some()
85 || self.platform.is_some()
86 }
87}
88
89#[derive(Debug, Clone)]
91pub struct EditedValues {
92 pub name: String,
94 pub description: Option<String>,
96 pub specification: Option<String>,
98 pub platform: Option<String>,
100 pub traceability: TraceabilityLinks,
102}
103
104impl EditedValues {
105 pub fn new(name: impl Into<String>) -> Self {
107 Self {
108 name: name.into(),
109 description: None,
110 specification: None,
111 platform: None,
112 traceability: TraceabilityLinks::default(),
113 }
114 }
115
116 pub fn with_description(mut self, description: Option<String>) -> Self {
118 self.description = description;
119 self
120 }
121
122 pub fn with_specification(mut self, specification: Option<String>) -> Self {
124 self.specification = specification;
125 self
126 }
127
128 pub fn with_platform(mut self, platform: Option<String>) -> Self {
130 self.platform = platform;
131 self
132 }
133
134 pub fn with_traceability(mut self, traceability: TraceabilityLinks) -> Self {
136 self.traceability = traceability;
137 self
138 }
139}