pub trait ChunkCache: Sync + Send {
// Required methods
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 Key,
range: &'life2 ChunkRange,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheRange>, ChunkCacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn put<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
key: &'life1 Key,
range: &'life2 ChunkRange,
chunk_byte_indices: &'life3 [u32],
data: &'life4 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ChunkCacheError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
}Expand description
ChunkCache is a trait for storing and fetching Xorb ranges. implementors are expected to return bytes for a key and a given chunk range (no compression or further deserialization should be required) Range inputs use chunk indices in an end exclusive way i.e. [start, end)
implementors are allowed to evict data, a get after a put is not required to be a cache hit.
Required Methods§
Sourcefn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 Key,
range: &'life2 ChunkRange,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheRange>, ChunkCacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 Key,
range: &'life2 ChunkRange,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheRange>, ChunkCacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
get should return an Ok() variant if significant error occurred, check the error variant for issues with IO or parsing contents etc.
if get returns an Ok(None) then there was no error, but there was a cache miss otherwise returns an Ok(Some(data)) where data matches exactly the bytes for the requested key and the requested chunk index range for that key
Given implementors are expected to be able to evict members there’s no guarantee that a previously put range will be a cache hit
key is required to be a valid XORB key range is intended to be an index range within the xorb with constraint 0 <= range.start < range.end <= num_chunks_in_xorb(key)
Sourcefn put<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
key: &'life1 Key,
range: &'life2 ChunkRange,
chunk_byte_indices: &'life3 [u32],
data: &'life4 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ChunkCacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn put<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
key: &'life1 Key,
range: &'life2 ChunkRange,
chunk_byte_indices: &'life3 [u32],
data: &'life4 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ChunkCacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
put should return Ok(()) if the put succeeded with no error, check the error variant for issues with validating the input, cache state, IO, etc.
put expects that chunk_byte_indices.len() is range.end - range.start + 1 with 1 entry for each start byte index for [range.start, range.end] the first entry must be 0 (start of first chunk in the data) the last entry must be data.len() i.e. the end of data, start of chunk past end
key is required to be a valid XORB key range is intended to be an index range within the xorb with constraint 0 <= range.start < range.end <= num_chunks_in_xorb(key)