Import a Loro snapshot from a remote replica. After merging the snapshot, `generator.observe(remote_hlc)` is called so the local generator incorporates the remote clock. A fresh `schema_hlc` is then generated via `generator.next()` so that any subsequent local writes have an HLC strictly greater than `remote_hlc`.
(
&mut self,
bytes: &[u8],
remote_hlc: Hlc,
generator: &HlcGenerator,
)
| 122 | /// subsequent local writes have an HLC strictly greater than |
| 123 | /// `remote_hlc`. |
| 124 | pub fn import_snapshot( |
| 125 | &mut self, |
| 126 | bytes: &[u8], |
| 127 | remote_hlc: Hlc, |
| 128 | generator: &HlcGenerator, |
| 129 | ) -> ArrayResult<()> { |
| 130 | let loro_bytes = strip_envelope(bytes)?; |
| 131 | self.doc |
| 132 | .import(loro_bytes) |
| 133 | .map_err(|e| ArrayError::LoroError { |
| 134 | detail: format!("loro import failed: {e}"), |
| 135 | })?; |
| 136 | generator.observe(remote_hlc)?; |
| 137 | self.schema_hlc = generator.next()?; |
| 138 | Ok(()) |
| 139 | } |
| 140 | |
| 141 | /// Import a Loro snapshot from a Raft-committed entry. |
| 142 | /// |