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

Method to_bytes

nodedb-wal/src/preamble.rs:90–99  ·  view source on GitHub ↗

Serialize to exactly [`PREAMBLE_SIZE`] bytes.

(&self)

Source from the content-addressed store, hash-verified

88
89 /// Serialize to exactly [`PREAMBLE_SIZE`] bytes.
90 pub fn to_bytes(&self) -> [u8; PREAMBLE_SIZE] {
91 let mut buf = [0u8; PREAMBLE_SIZE];
92 buf[0..4].copy_from_slice(&self.magic);
93 buf[4..6].copy_from_slice(&self.version.to_le_bytes());
94 buf[6] = self.cipher_alg;
95 buf[7] = self.kid;
96 buf[8..12].copy_from_slice(&self.epoch);
97 // buf[12..16] stays zero (reserved)
98 buf
99 }
100
101 /// Deserialize and validate a preamble, checking magic and version.
102 ///

Callers 15

wal_preamble_roundtripFunction · 0.45
seg_preamble_roundtripFunction · 0.45
wrong_magic_rejectedFunction · 0.45
reserved_bytes_are_zeroFunction · 0.45
write_record_deferredMethod · 0.45
epoch_tamper_rejectedFunction · 0.45
set_encryption_ringMethod · 0.45
appendMethod · 0.45

Calls

no outgoing calls