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

Method to_bytes

nodedb-columnar/src/format.rs:54–61  ·  view source on GitHub ↗

Serialize the header to bytes.

(&self)

Source from the content-addressed store, hash-verified

52
53 /// Serialize the header to bytes.
54 pub fn to_bytes(&self) -> [u8; HEADER_SIZE] {
55 let mut buf = [0u8; HEADER_SIZE];
56 buf[0..4].copy_from_slice(&self.magic);
57 buf[4] = self.version_major;
58 buf[5] = self.version_minor;
59 buf[6] = self.endianness;
60 buf
61 }
62
63 /// Parse a header from bytes. Returns None if magic/version is invalid.
64 pub fn from_bytes(data: &[u8]) -> Result<Self, crate::error::ColumnarError> {

Callers 8

header_roundtripFunction · 0.45
header_invalid_magicFunction · 0.45
header_compatible_minorFunction · 0.45
footer_roundtripFunction · 0.45
footer_crc_mismatchFunction · 0.45
write_segmentMethod · 0.45

Calls 2

to_stringMethod · 0.80
lenMethod · 0.45

Tested by 7

header_roundtripFunction · 0.36
header_invalid_magicFunction · 0.36
header_compatible_minorFunction · 0.36
footer_roundtripFunction · 0.36
footer_crc_mismatchFunction · 0.36