Export the full Loro snapshot as an enveloped byte buffer. The returned bytes have the format: `[LORO_FORMAT_VERSION: u8][loro snapshot bytes…]` Pass the result to [`SchemaDoc::import_snapshot`] (or [`SchemaDoc::import_snapshot_replicated`]) on another replica to converge schema state.
(&self)
| 103 | /// [`SchemaDoc::import_snapshot_replicated`]) on another replica to |
| 104 | /// converge schema state. |
| 105 | pub fn export_snapshot(&self) -> ArrayResult<Vec<u8>> { |
| 106 | let loro_bytes = self.doc.export(loro::ExportMode::Snapshot).map_err(|e| { |
| 107 | ArrayError::SegmentCorruption { |
| 108 | detail: format!("loro snapshot export failed: {e}"), |
| 109 | } |
| 110 | })?; |
| 111 | let mut envelope = Vec::with_capacity(1 + loro_bytes.len()); |
| 112 | envelope.push(LORO_FORMAT_VERSION); |
| 113 | envelope.extend_from_slice(&loro_bytes); |
| 114 | Ok(envelope) |
| 115 | } |
| 116 | |
| 117 | /// Import a Loro snapshot from a remote replica. |
| 118 | /// |