self.io.read_buf(buf)
}
+ /// Allocates additional space in vector and reads data there. Partial read is treated as success.
+ pub fn read_extend(&mut self, buf: &mut Vec<u8>, add_size: usize) -> ByteIOResult<usize> {
+ let cur_size = buf.len();
+ buf.resize(cur_size + add_size, 0);
+ self.io.read_buf(&mut buf[cur_size..])
+ }
+
/// Reads data into provided buffer. Partial read is treated as success.
pub fn read_buf_some(&mut self, buf: &mut [u8]) -> ByteIOResult<usize> {
self.io.read_buf_some(buf)
}
if is_video {
validate!(self.v_den != 0);
- let cur_size = self.video_buf.len();
- let new_size = cur_size + size;
- self.video_buf.resize(new_size, 0);
- br.read_buf(&mut self.video_buf[cur_size..])?;
+ br.read_extend(&mut self.video_buf, size)?;
if (hdr >> 4) == 2 {
let mut buf = Vec::new();
std::mem::swap(&mut self.video_buf, &mut buf);