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

Method to_bytes

nodedb-wal/src/temporal_purge.rs:84–99  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

82 }
83
84 pub fn to_bytes(&self) -> Result<Vec<u8>> {
85 let name_bytes = self.name.as_bytes();
86 if name_bytes.len() > MAX_COLLECTION_NAME_LEN {
87 return Err(WalError::PayloadTooLarge {
88 size: name_bytes.len(),
89 max: MAX_COLLECTION_NAME_LEN,
90 });
91 }
92 let mut buf = Vec::with_capacity(self.wire_size());
93 buf.push(self.engine as u8);
94 buf.extend_from_slice(&(name_bytes.len() as u32).to_le_bytes());
95 buf.extend_from_slice(name_bytes);
96 buf.extend_from_slice(&self.cutoff_system_ms.to_le_bytes());
97 buf.extend_from_slice(&self.purged_count.to_le_bytes());
98 Ok(buf)
99 }
100
101 pub fn from_bytes(buf: &[u8]) -> Result<Self> {
102 if buf.len() < 1 + 4 {

Callers 5

roundtripFunction · 0.45
array_variant_roundtripFunction · 0.45
rejects_truncatedFunction · 0.45

Calls 4

as_bytesMethod · 0.45
lenMethod · 0.45
wire_sizeMethod · 0.45
pushMethod · 0.45

Tested by 5

roundtripFunction · 0.36
array_variant_roundtripFunction · 0.36
rejects_truncatedFunction · 0.36