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

Method to_bytes

nodedb-array/src/sync/hlc.rs:83–89  ·  view source on GitHub ↗

Encode as 18 bytes in big-endian order for stable byte-comparable sort. Layout: `physical_ms` (8 bytes) | `logical` (2 bytes) | `replica_id` (8 bytes).

(&self)

Source from the content-addressed store, hash-verified

81 ///
82 /// Layout: `physical_ms` (8 bytes) | `logical` (2 bytes) | `replica_id` (8 bytes).
83 pub fn to_bytes(&self) -> [u8; 18] {
84 let mut out = [0u8; 18];
85 out[0..8].copy_from_slice(&self.physical_ms.to_be_bytes());
86 out[8..10].copy_from_slice(&self.logical.to_be_bytes());
87 out[10..18].copy_from_slice(&self.replica_id.0.to_be_bytes());
88 out
89 }
90
91 /// Decode from a 18-byte big-endian slice produced by [`Hlc::to_bytes`].
92 ///

Callers 7

to_bytes_roundtripFunction · 0.45
already_seenMethod · 0.45
apply_putMethod · 0.45
apply_deleteMethod · 0.45
apply_eraseMethod · 0.45
appendMethod · 0.45

Calls

no outgoing calls

Tested by 2

to_bytes_roundtripFunction · 0.36