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

Method hash_to_index

atomic-core/src/change/format_v3/compact/compactor.rs:253–261  ·  view source on GitHub ↗

Convert an `Option ` to a `HashIndex`. - `None` → `HASH_INDEX_NONE` - `Some(hash)` → looked up in the dedup table

(&self, hash: &Option<Hash>)

Source from the content-addressed store, hash-verified

251 /// - `None` → `HASH_INDEX_NONE`
252 /// - `Some(hash)` → looked up in the dedup table
253 pub(super) fn hash_to_index(&self, hash: &Option<Hash>) -> FormatResult<HashIndex> {
254 match hash {
255 None => Ok(HASH_INDEX_NONE),
256 Some(h) => {
257 let bytes = h.as_bytes();
258 self.table.require(bytes)
259 }
260 }
261 }
262
263 /// Convert a `HashIndex` to an `Option<Hash>`.
264 ///

Callers 3

compact_positionMethod · 0.80
compact_graph_nodeMethod · 0.80
compact_new_edgeMethod · 0.80

Calls 2

as_bytesMethod · 0.45
requireMethod · 0.45

Tested by

no test coverage detected