Parse and verify a view manifest downloaded from the remote. Validates three things before the manifest is trusted: 1. The text parses structurally (header + base32 change log). 2. The header names the view that was requested. 3. The declared merkle state equals the fold of the change log. # Arguments `view` - The view name that was requested from the remote `text` - The raw manifest text retu
(view: &str, text: &str, url: &str)
| 389 | /// * `text` - The raw manifest text returned by the server |
| 390 | /// * `url` - The remote URL (for error context) |
| 391 | pub fn parse_remote_manifest(view: &str, text: &str, url: &str) -> CliResult<ViewManifest> { |
| 392 | let manifest = ViewManifest::parse(text).map_err(|e| CliError::RemoteError { |
| 393 | message: format!("Corrupt manifest for view '{}': {}", view, e), |
| 394 | url: Some(url.to_string()), |
| 395 | })?; |
| 396 | |
| 397 | if manifest.name != view { |
| 398 | return Err(CliError::RemoteError { |
| 399 | message: format!( |
| 400 | "Manifest name mismatch: requested view '{}', server sent '{}'", |
| 401 | view, manifest.name |
| 402 | ), |
| 403 | url: Some(url.to_string()), |
| 404 | }); |
| 405 | } |
| 406 | |
| 407 | manifest.verify().map_err(|e| CliError::RemoteError { |
| 408 | message: format!("Corrupt manifest for view '{}': {}", view, e), |
| 409 | url: Some(url.to_string()), |
| 410 | })?; |
| 411 | |
| 412 | Ok(manifest) |
| 413 | } |
| 414 | |
| 415 | /// Order manifests so every parent is applied before its children. |
| 416 | /// |