Validate canonical schema-version-2 facts and derived content hash.
(&self)
| 322 | |
| 323 | /// Validate canonical schema-version-2 facts and derived content hash. |
| 324 | pub fn validate_v2(&self) -> Result<(), ChangeError> { |
| 325 | self.hashed.validate_v2()?; |
| 326 | let computed = Hash::of(&self.contents); |
| 327 | if computed != self.hashed.contents_hash { |
| 328 | return Err(ChangeError::ContentsHashMismatch { |
| 329 | claimed: self.hashed.contents_hash.to_string(), |
| 330 | computed: computed.to_string(), |
| 331 | }); |
| 332 | } |
| 333 | if let Some(span) = &self.hashed.span { |
| 334 | span.validate_content_ranges(self.contents.len() as u64) |
| 335 | .map_err(|error| ChangeError::Invalid(error.to_string()))?; |
| 336 | } |
| 337 | Ok(()) |
| 338 | } |
| 339 | |
| 340 | /// Get the change message. |
| 341 | pub fn message(&self) -> &str { |
no test coverage detected