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

Method read_from

atomic-core/src/change/format_v3/hash_table.rs:624–638  ·  view source on GitHub ↗

Read a hash table from a reader. Reads `count × 32` bytes and reconstructs the table with bidirectional lookup support. The first hash read becomes index 0 (the self hash). # Arguments `reader` - The source reader, positioned at the start of the hash table. `count` - Number of hash entries to read (from the file header's `hash_table_entries` field). # Errors - I/O error if fewer than `count ×

(reader: &mut R, count: u32)

Source from the content-addressed store, hash-verified

622 /// assert_eq!(loaded.resolve(0).unwrap(), &[42u8; 32]);
623 /// ```
624 pub fn read_from<R: Read>(reader: &mut R, count: u32) -> FormatResult<Self> {
625 if count as usize > MAX_HASH_TABLE_ENTRIES {
626 return Err(FormatError::HashTableFull);
627 }
628
629 let mut hashes = Vec::with_capacity(count as usize);
630 let mut buf = [0u8; HASH_SIZE];
631
632 for _ in 0..count {
633 reader.read_exact(&mut buf)?;
634 hashes.push(buf);
635 }
636
637 Self::from_hashes(hashes)
638 }
639
640 /// Merge another set of hashes into this table.
641 ///

Callers

nothing calls this directly

Calls 2

read_exactMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected