code: def read(data, fmt_str):
      
      size = struct.calcsize(fmt_str)
      return struct.unpack(fmt_str, data[:size]), data[size:]
docs: Reads input bytes and extract the given structure. Returns both the read
      elements and the remaining data
  
      :param data: Data as bytes
      :param fmt_str: Struct unpack format string
      :return: A tuple (results as tuple, remaining data)