/// Handle read_at requests with the given data and offset until all data after offset is read.
///
/// # Panics
///
/// Panics on error or if data not read sequentially.
Handle read_at requests with the given data and offset until all data after offset is read.
Handle read_at requests with the given data and offset until all data after offset is read .
pub async fn expect_read_at(mut self, data: &[u8], start_offset: usize) -> Self {
        let mut expected_offset = start_offset;
        while expected_offset < data.len() {
            match self.stream.next().await {
                Some(Ok(FileRequest::ReadAt { count, offset, responder })) => {
                    let offset: usize = offset.try_into().unwrap();
                    assert_eq!(offset, expected_offset);
                    let count = min(count.try_into().unwrap(), data.len() - offset);
                    responder.send(Status::OK.into_raw(), &data[offset..offset + count]).unwrap();
                    expected_offset += count;
                }
                other => panic!("unexpected request: {:?}", other),
            }
        }
        self
    }
pub async fn expect_read_at ( mut self , data : & [ u8 ] , start_offset : usize ) -> Self { let mut expected_offset = start_offset ; while expected_offset < data . len ( ) { match self . stream . next ( ) . await { Some ( Ok ( FileRequest :: ReadAt { count , offset , responder } ) ) => { let offset : usize = offset . try_into ( ) . unwrap ( ) ; assert_eq ! ( offset expected_offset ) ; let count = min ( count . try_into ( ) . unwrap ( ) , data . len ( ) - offset ) ; responder . send ( Status :: OK . into_raw ( ) , & data [ offset .. offset + count ] ) . unwrap ( ) ; expected_offset += count ; } other => panic ! ( " " other ) , } } self }
Handle read_at requests with the given data and offset until all data after offset is read.
Handle read_at requests with the given data and offset until all data after offset is read .
mut self
data
&[u8]
start_offset
usize
panics
Panics on error or if data not read sequentially.
Panics on error or if data not read sequentially .