mod config;
mod file;
mod fs;
mod local_state;
pub mod pipeline;
#[cfg(test)]
mod tests;
use std::ops::Range;
pub use config::DiskCacheConfig;
pub use file::DiskCache;
pub use fs::{DiskCacheFs, DiskCacheFsContext};
use crate::common::universal_io::{UniversalRead, UniversalReadFs};
pub trait DiskCacheRemote:
UniversalRead<
Fs: Clone + Send + Sync + UniversalReadFs<OpenExtra: Clone + Send + Sync>,
OwnedReadPipeline<()>: Send,
> + Clone
{
}
impl<R> DiskCacheRemote for R
where
R: UniversalRead + Clone,
R::Fs: Clone + Send + Sync,
<R::Fs as UniversalReadFs>::OpenExtra: Clone + Send + Sync,
R::OwnedReadPipeline<()>: Send,
{
}
const BLOCK_SIZE: usize = 16 * 1024;
fn to_block_range(byte_range: Range<u64>) -> Range<u32> {
let start = (byte_range.start / BLOCK_SIZE as u64) as u32;
if byte_range.start >= byte_range.end {
return start..start;
}
let end = byte_range.end.div_ceil(BLOCK_SIZE as u64) as u32;
start..end
}