MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / to_bytes

Method to_bytes

atomic-core/tests/inode_graph_test.rs:73–80  ·  view source on GitHub ↗

Encode as bytes for use as a redb key. Layout: [inode: 8 bytes][change: 8 bytes][start: 8 bytes][end: 8 bytes]

(&self)

Source from the content-addressed store, hash-verified

71 /// Encode as bytes for use as a redb key.
72 /// Layout: [inode: 8 bytes][change: 8 bytes][start: 8 bytes][end: 8 bytes]
73 pub fn to_bytes(&self) -> [u8; 32] {
74 let mut bytes = [0u8; 32];
75 bytes[0..8].copy_from_slice(&self.inode.0.to_le_bytes());
76 bytes[8..16].copy_from_slice(&self.span.change.0.to_le_bytes());
77 bytes[16..24].copy_from_slice(&self.span.start.0.to_le_bytes());
78 bytes[24..32].copy_from_slice(&self.span.end.0.to_le_bytes());
79 bytes
80 }
81
82 /// Decode from bytes.
83 pub fn from_bytes(bytes: &[u8; 32]) -> Self {

Calls 1

to_le_bytesMethod · 0.80

Tested by

no test coverage detected