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

Function vertex_to_bytes

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

Encode a Span as 24 bytes for use as a redb key.

(v: &GraphNode<NodeId>)

Source from the content-addressed store, hash-verified

229
230/// Encode a Span as 24 bytes for use as a redb key.
231fn vertex_to_bytes(v: &GraphNode<NodeId>) -> [u8; 24] {
232 let mut bytes = [0u8; 24];
233 bytes[0..8].copy_from_slice(&v.change.0.to_le_bytes());
234 bytes[8..16].copy_from_slice(&v.start.0.to_le_bytes());
235 bytes[16..24].copy_from_slice(&v.end.0.to_le_bytes());
236 bytes
237}
238
239/// Decode a Span from 24 bytes.
240fn vertex_from_bytes(bytes: &[u8; 24]) -> GraphNode<NodeId> {

Callers 3

test_root_vertexFunction · 0.85

Calls 1

to_le_bytesMethod · 0.80

Tested by

no test coverage detected