class BinData::IO::Read

def with_buffer(n, &block)

calls inside the +block+ will be contained within this buffer.
Sets a buffer of +n+ bytes on the io stream. Any reading or seeking
def with_buffer(n, &block)
  prev = @buffer_end_pos
  if prev
    avail = prev - offset
    n = avail if n > avail
  end
  @buffer_end_pos = offset + n
  begin
    block.call
    read
  ensure
    @buffer_end_pos = prev
  end
end