(&self, start: u64, length: usize)
| 97 | } |
| 98 | |
| 99 | fn get_bytes(&self, start: u64, length: usize) -> Result<Bytes> { |
| 100 | let mut buffer = Vec::with_capacity(length); |
| 101 | let mut reader = self.try_clone()?; |
| 102 | reader.seek(SeekFrom::Start(start))?; |
| 103 | let read = reader.take(length as _).read_to_end(&mut buffer)?; |
| 104 | |
| 105 | if read != length { |
| 106 | return Err(eof_err!( |
| 107 | "Expected to read {} bytes, read only {}", |
| 108 | length, |
| 109 | read |
| 110 | )); |
| 111 | } |
| 112 | Ok(buffer.into()) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | impl Length for Bytes { |