Create from state that can be serialized
(state: &T)
| 133 | |
| 134 | /// Create from state that can be serialized |
| 135 | pub fn new_from_state<T>(state: &T) -> Result<Self, MigratableError> |
| 136 | where |
| 137 | T: Serialize, |
| 138 | { |
| 139 | let state = serde_json::to_string(state) |
| 140 | .map_err(|e| MigratableError::Snapshot(anyhow!("Error serialising: {e}")))?; |
| 141 | |
| 142 | Ok(SnapshotData { state }) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /// Data structure to describe snapshot data |