Try to build the provenance, returning an error if required fields are missing.
(self)
| 240 | |
| 241 | /// Try to build the provenance, returning an error if required fields are missing. |
| 242 | pub fn try_build(self) -> Result<Provenance, &'static str> { |
| 243 | if self.vendor.is_none() { |
| 244 | return Err("Vendor is required"); |
| 245 | } |
| 246 | if self.model.is_none() || self.model.as_ref().map(|m| m.is_empty()).unwrap_or(true) { |
| 247 | return Err("Model is required"); |
| 248 | } |
| 249 | |
| 250 | Ok(self.build()) |
| 251 | } |
| 252 | } |