MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / decode_operation_heads

Function decode_operation_heads

atomic-core/src/operation/codec.rs:218–234  ·  view source on GitHub ↗

Decode a versioned canonical sorted multi-head value.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

216
217/// Decode a versioned canonical sorted multi-head value.
218pub fn decode_operation_heads(bytes: &[u8]) -> Result<OperationHeads, OperationCodecError> {
219 let mut decoder = Decoder::new(bytes)?;
220 decoder.expect_version(OPERATION_HEADS_VERSION, "operation heads")?;
221 let count = decoder.read_count("operation heads")?;
222 let mut heads = Vec::with_capacity(count);
223 for _ in 0..count {
224 heads.push(decoder.read_operation_id()?);
225 }
226 decoder.finish()?;
227 let heads = OperationHeads::from_canonical(heads)?;
228 if encode_operation_heads(&heads)? != bytes {
229 return Err(OperationCodecError::new(
230 "operation heads are not canonically encoded",
231 ));
232 }
233 Ok(heads)
234}
235
236/// Encode a fixed-width operation-head scope key.
237pub fn encode_operation_scope(scope: OperationScope) -> [u8; 17] {

Callers 4

get_operation_headsMethod · 0.85
list_operation_headsMethod · 0.85
get_operation_headsMethod · 0.85
list_operation_headsMethod · 0.85

Calls 6

encode_operation_headsFunction · 0.85
expect_versionMethod · 0.80
read_countMethod · 0.80
read_operation_idMethod · 0.80
pushMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected