/// Read the given bytes from the given file in the given cache
/// Spawns a new thread to do the read because it is blocking
Read the given bytes from the given file in the given cache
Spawns a new thread to do the read because it is blocking
Read the given bytes from the given file in the given cache Spawns a new thread to do the read because it is blocking
async fn read_from_cache(
        cache: Arc<RangeCache>,
        downloader: &'static str,
        file: &'static str,
        start: u64,
        length: usize,
    ) -> Result<Vec<u8>> {
        tokio::task::spawn_blocking(move || -> Result<Vec<u8>> {
            let mut reader =
                cache.get(downloader.to_owned(), file.to_owned(), start, length)?;
            let mut content = vec![];
            reader.read_to_end(&mut content)?;
            Ok(content)
        })
        .await
        .unwrap()
    }
async fn read_from_cache ( cache : Arc < RangeCache > , downloader : & ' static str , file : & ' static str , start : u64 , length : usize , ) -> Result < Vec < u8 > > { tokio :: task :: spawn_blocking ( move | | -> Result < Vec < u8 > > { let mut reader = cache . get ( downloader . to_owned ( ) , file . to_owned ( ) , start , length ) ? ; let mut content = vec ! [ ] ; reader . read_to_end ( & mut content ) ? ; Ok ( content ) } ) . await . unwrap ( ) }
Read the given bytes from the given file in the given cache
Spawns a new thread to do the read because it is blocking
Read the given bytes from the given file in the given cache Spawns a new thread to do the read because it is blocking
cache
Arc<RangeCache>
downloader
&'static str
file
&'static str
start
u64
length
usize