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

Function metadata_transition_ranges

atomic-core/src/operation/codec.rs:1567–1592  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

1565 }
1566
1567 fn metadata_transition_ranges(bytes: &[u8]) -> Vec<std::ops::Range<usize>> {
1568 let mut decoder = Decoder::new(bytes).unwrap();
1569 let encoding_version = decoder.read_u8().unwrap();
1570 assert_eq!(encoding_version, OPERATION_VERSION_V2);
1571 let parent_count = decoder.read_count("operation parents").unwrap();
1572 for _ in 0..parent_count {
1573 decoder.read_operation_id().unwrap();
1574 }
1575 decoder
1576 .read_operation_kind(encoding_version)
1577 .expect("operation kind");
1578 if decoder.read_optional_tag("operation relation").unwrap() {
1579 decoder.read_operation_relation().unwrap();
1580 }
1581 decoder.read_optional_working_copy().unwrap();
1582 decoder.read_repo_state().unwrap();
1583 decoder.read_repo_state().unwrap();
1584 let metadata_count = decoder.read_count("metadata transitions").unwrap();
1585 let mut ranges = Vec::with_capacity(metadata_count);
1586 for _ in 0..metadata_count {
1587 let start = decoder.offset;
1588 decoder.read_metadata_transition().unwrap();
1589 ranges.push(start..decoder.offset);
1590 }
1591 ranges
1592 }
1593
1594 #[test]
1595 fn operation_v1_golden_vector_and_roundtrip() {

Calls 11

read_u8Method · 0.80
read_countMethod · 0.80
read_operation_idMethod · 0.80
read_operation_kindMethod · 0.80
read_optional_tagMethod · 0.80
read_repo_stateMethod · 0.80
unwrapMethod · 0.45
pushMethod · 0.45