MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / to_bytes

Method to_bytes

nodedb-wal/src/record/header.rs:74–87  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

72
73impl RecordHeader {
74 pub fn to_bytes(&self) -> [u8; HEADER_SIZE] {
75 let mut buf = [0u8; HEADER_SIZE];
76 buf[0..4].copy_from_slice(&self.magic.to_le_bytes());
77 buf[4..6].copy_from_slice(&self.format_version.to_le_bytes());
78 buf[6..10].copy_from_slice(&self.record_type.to_le_bytes());
79 buf[10..18].copy_from_slice(&self.lsn.to_le_bytes());
80 buf[18..26].copy_from_slice(&self.tenant_id.to_le_bytes());
81 buf[26..30].copy_from_slice(&self.vshard_id.to_le_bytes());
82 buf[30..34].copy_from_slice(&self.payload_len.to_le_bytes());
83 buf[34..42].copy_from_slice(&self.database_id.to_le_bytes());
84 buf[42..50].copy_from_slice(&self.reserved);
85 buf[50..54].copy_from_slice(&self.crc32c.to_le_bytes());
86 buf
87 }
88
89 pub fn from_bytes(buf: &[u8; HEADER_SIZE]) -> Self {
90 let mut reserved = [0u8; 8];

Callers 12

compute_checksumMethod · 0.45
header_roundtripFunction · 0.45
database_id_roundtripFunction · 0.45
newMethod · 0.45
decrypt_payloadMethod · 0.45
decrypt_payload_ringMethod · 0.45
anchor_payload_in_recordFunction · 0.45
tombstone_recordFunction · 0.45

Calls

no outgoing calls

Tested by 7

header_roundtripFunction · 0.36
database_id_roundtripFunction · 0.36
anchor_payload_in_recordFunction · 0.36