Encode a path-claim event using a stable, fixed-width big-endian layout.
(event: &PathClaimEvent)
| 146 | |
| 147 | /// Encode a path-claim event using a stable, fixed-width big-endian layout. |
| 148 | pub fn encode_path_claim_event(event: &PathClaimEvent) -> [u8; PATH_CLAIM_EVENT_SIZE] { |
| 149 | let mut bytes = [0u8; PATH_CLAIM_EVENT_SIZE]; |
| 150 | bytes[0] = PATH_CLAIM_EVENT_VERSION; |
| 151 | put_u64(&mut bytes, 1, event.event_change.get()); |
| 152 | bytes[9..13].copy_from_slice(&event.operation_index.to_be_bytes()); |
| 153 | put_u64(&mut bytes, 13, event.claim.claimant.change.get()); |
| 154 | put_u64(&mut bytes, 21, event.claim.claimant.pos.get()); |
| 155 | bytes[29] = event.kind as u8; |
| 156 | bytes[30] = event.state as u8; |
| 157 | put_u64(&mut bytes, 31, event.claim.parent.change.get()); |
| 158 | put_u64(&mut bytes, 39, event.claim.parent.start.get()); |
| 159 | put_u64(&mut bytes, 47, event.claim.parent.end.get()); |
| 160 | put_u64(&mut bytes, 55, event.claim.name.change.get()); |
| 161 | put_u64(&mut bytes, 63, event.claim.name.start.get()); |
| 162 | put_u64(&mut bytes, 71, event.claim.name.end.get()); |
| 163 | put_u64(&mut bytes, 79, event.claim.introduced_by.get()); |
| 164 | bytes |
| 165 | } |
| 166 | |
| 167 | /// Decode and validate one fixed-width path-claim event. |
| 168 | pub fn decode_path_claim_event( |