Mint the content-addressed `ViewSnapshot` for a view from its local manifest and the remote's current snapshot key (`prev`, for the CAS-on-`prev` chain). The `own_set_id` fold matches the server's `from_manifest` bridge exactly, so client and server mint byte-identical objects with identical content keys.
(manifest: &ViewManifest, prev: Option<String>)
| 85 | /// The `own_set_id` fold matches the server's `from_manifest` bridge exactly, so |
| 86 | /// client and server mint byte-identical objects with identical content keys. |
| 87 | fn mint_view_snapshot(manifest: &ViewManifest, prev: Option<String>) -> ViewSnapshot { |
| 88 | let own_changes: Vec<String> = manifest.changes.iter().map(|h| h.to_base32()).collect(); |
| 89 | let mut acc = SetId::ZERO; |
| 90 | for h in &manifest.changes { |
| 91 | acc = acc.add(h); |
| 92 | } |
| 93 | let own_set_id = acc.to_base32(); |
| 94 | let merkle_state = if manifest.changes.is_empty() { |
| 95 | None |
| 96 | } else { |
| 97 | Some(manifest.state.to_base32()) |
| 98 | }; |
| 99 | let scope = if manifest.scope.is_draft() { |
| 100 | ViewScopeLabel::Draft |
| 101 | } else { |
| 102 | ViewScopeLabel::Shared |
| 103 | }; |
| 104 | ViewSnapshot::new( |
| 105 | scope, |
| 106 | manifest.parent.clone(), |
| 107 | prev.into_iter().collect(), |
| 108 | own_changes, |
| 109 | own_set_id, |
| 110 | merkle_state, |
| 111 | ) |
| 112 | } |
| 113 | |
| 114 | // Constants |
| 115 |