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