pub fn read_to(&mut self, offset: u64, mut buf: &mut [u8]) -> Result<usize> {
        if offset != self.offset {
            self.reader.seek(SeekFrom::Start(offset))?;
            self.offset = offset;
        }
        loop {
            match self.reader.read(buf) {
                Ok(0) => break,
                Ok(n) => {
                    self.offset += n as u64;
                    buf = &mut buf[n..];
                }
                Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => {}
                Err(e) => return Err(Error::Io(e)),
            }
        }
        Ok((self.offset - offset) as usize)
    }
/// Polls bytes from the file. Stops only when the buffer is filled or
/// reaching the "end of file".
Polls bytes from the file. Stops only when the buffer is filled or
reaching the "end of file".
Polls bytes from the file . Stops only when the buffer is filled or reaching the " end of file " .
pub fn read_to(&mut self, offset: u64, mut buf: &mut [u8]) -> Result<usize> {
        if offset != self.offset {
            self.reader.seek(SeekFrom::Start(offset))?;
            self.offset = offset;
        }
        loop {
            match self.reader.read(buf) {
                Ok(0) => break,
                Ok(n) => {
                    self.offset += n as u64;
                    buf = &mut buf[n..];
                }
                Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => {}
                Err(e) => return Err(Error::Io(e)),
            }
        }
        Ok((self.offset - offset) as usize)
    }
pub fn read_to ( & mut self , offset : u64 , mut buf : & mut [ u8 ] ) -> Result < usize > { if offset != self . offset { self . reader . seek ( SeekFrom :: Start ( offset ) ) ? ; self . offset = offset ; } loop { match self . reader . read ( buf ) { Ok ( 0 ) => break , Ok ( n ) => { self . offset += n as u64 ; buf = & mut buf [ n .. ] ; } Err ( ref e ) if e . kind ( ) == std :: io :: ErrorKind :: Interrupted => { } Err ( e ) => return Err ( Error :: Io ( e ) ) , } } Ok ( ( self . offset - offset ) as usize ) }
Polls bytes from the file.
Polls bytes from the file .
&mut self
offset
u64
buf
&mut [u8]