code: def read_func(self, func, num_bytes=None):
          
          # only advance if func succeeds
          res = func(self.get_next(num_bytes))
          self.skip(num_bytes)
          return res
docs: Parse data from the current buffer offset using a function.