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

Method to_bytes

nodedb/src/storage/segment.rs:59–68  ·  view source on GitHub ↗

Serialize the footer to bytes.

(&self)

Source from the content-addressed store, hash-verified

57
58 /// Serialize the footer to bytes.
59 pub fn to_bytes(&self) -> [u8; FOOTER_SIZE] {
60 let mut buf = [0u8; FOOTER_SIZE];
61 buf[0..4].copy_from_slice(&SEGMENT_MAGIC);
62 buf[4..6].copy_from_slice(&self.format_version.to_le_bytes());
63 buf[6..38].copy_from_slice(&self.created_by);
64 buf[38..42].copy_from_slice(&self.checksum.to_le_bytes());
65 buf[42..50].copy_from_slice(&self.min_lsn.as_u64().to_le_bytes());
66 buf[50..58].copy_from_slice(&self.max_lsn.as_u64().to_le_bytes());
67 buf
68 }
69
70 /// Deserialize a footer from bytes.
71 pub fn from_bytes(buf: &[u8; FOOTER_SIZE]) -> crate::Result<Self> {

Callers 7

write_toMethod · 0.45
write_encrypted_segmentFunction · 0.45
encrypt_segment_bytesFunction · 0.45
roundtrip_bytesFunction · 0.45
make_core_snapshotFunction · 0.45

Calls 1

as_u64Method · 0.45

Tested by 2

roundtrip_bytesFunction · 0.36