Canonical bytes: magic + version + deterministic postcard payload of the normalized (store-independent) object.
(&self)
| 276 | /// Canonical bytes: magic + version + deterministic postcard payload of |
| 277 | /// the normalized (store-independent) object. |
| 278 | pub fn canonical_bytes(&self) -> Result<Vec<u8>, ConflictObjectError> { |
| 279 | let normalized = self.normalized(); |
| 280 | let mut bytes = Vec::with_capacity(64); |
| 281 | bytes.extend_from_slice(CONFLICT_SET_MAGIC); |
| 282 | bytes.extend_from_slice(&normalized.version.to_le_bytes()); |
| 283 | let payload = postcard::to_allocvec(&normalized) |
| 284 | .map_err(|error| ConflictObjectError::Encode(error.to_string()))?; |
| 285 | bytes.extend_from_slice(&payload); |
| 286 | Ok(bytes) |
| 287 | } |
| 288 | |
| 289 | /// Decode canonical bytes, failing closed on unknown versions. |
| 290 | pub fn decode(bytes: &[u8]) -> Result<Self, ConflictObjectError> { |