/// Read multiple range of data from blob into the provided slices
Read multiple range of data from blob into the provided slices
Read multiple range of data from blob into the provided slices
fn readv(
        &self,
        blob_id: &str,
        bufs: &[VolatileSlice],
        offset: u64,
        max_size: usize,
    ) -> Result<usize> {
        if bufs.len() == 1 && max_size >= bufs[0].len() {
            let buf = unsafe { std::slice::from_raw_parts_mut(bufs[0].as_ptr(), bufs[0].len()) };
            self.read(blob_id, buf, offset)
        } else {
            // Use std::alloc to avoid zeroing the allocated buffer.
            let size = bufs.iter().fold(0usize, move |size, s| size + s.len());
            let layout = std::alloc::Layout::from_size_align(size, 8).unwrap();
            let ptr = unsafe { std::alloc::alloc(layout) };
            let data = unsafe { std::slice::from_raw_parts_mut(ptr, size) };
            self.read(blob_id, data, offset)?;
            let result = copyv(&data, bufs, offset, max_size);
            unsafe { std::alloc::dealloc(ptr, layout) };
            result
        }
    }
fn readv ( & self , blob_id : & str , bufs : & [ VolatileSlice ] , offset : u64 , max_size : usize , ) -> Result < usize > { if bufs . len ( ) == 1 && max_size >= bufs [ 0 ] . len ( ) { let buf = unsafe { std :: slice :: from_raw_parts_mut ( bufs [ 0 ] . as_ptr ( ) , bufs [ 0 ] . len ( ) ) } ; self . read ( blob_id , buf , offset ) } else { // Use std::alloc to avoid zeroing the allocated buffer. let size = bufs . iter ( ) . fold ( 0usize , move | size , s | size + s . len ( ) ) ; let layout = std :: alloc :: Layout :: from_size_align ( size , 8 ) . unwrap ( ) ; let ptr = unsafe { std :: alloc :: alloc ( layout ) } ; let data = unsafe { std :: slice :: from_raw_parts_mut ( ptr , size ) } ; self . read ( blob_id , data , offset ) ? ; let result = copyv ( & data , bufs , offset , max_size ) ; unsafe { std :: alloc :: dealloc ( ptr , layout ) } ; result } }
Read multiple range of data from blob into the provided slices
Read multiple range of data from blob into the provided slices
&self
blob_id
&str
bufs
&[VolatileSlice]
offset
u64
max_size
usize