Skip to main content

MemoryChunkSource

MemoryChunkSource is an implementation of ChunkSource that stores all chunks in memory.
This is useful for fast temporary operations, testing, or small datasets.


Methods​

MethodReturnsDescription
get_chunk(hash)Result<Vec<u8>, ChunkError>Returns a single chunk by its hash.
get_chunks(hashes, options)Result<HashMap<String, Vec<u8>>, ChunkError>Method to fetch multiple chunks concurrently.
has_chunk(hash)boolChecks if a chunk exists in memory.
set_chunk(hash, data)()Adds or updates a chunk in memory.

Notes​

  • Ideal for small datasets or unit testing.

  • Not suitable for very large datasets due to memory limitations.

  • Implements the ChunkSource interface fully, so it can be swapped with DiskChunkSource or StorageChunkSource.