@staticmethod
def should_halt(seq, stream, values, context, loaded_fields):
    """Determine if the deserializer should stop reading from the input.

        This function should return ``True`` to indicate loading for this field
        should stop, or ``False`` to continue adding elements.

        The default implementation does the following:

        - If ``count`` is an integer, it compares ``count`` against the length
          of ``values``. If ``len(values)`` is equal to or more than ``count``
          it'll return ``True`` (halt), ``False`` otherwise.
        - If ``count`` is a :class:`~binobj.fields.base.Field`, that field should
          already have been loaded and in ``loaded_fields``. The expected array
          size is taken from there, and compared as above.
        - If ``count`` is a string, it's the name of a field already loaded and
          in ``loaded_fields``. The expected array size is taken from there, and
          compared as above.
        - Otherwise, the function assumes the array ends at EOF and only returns
          ``True`` if there's no more data in the stream.

        Subclasses' implementations must handle all four cases.

        :param Array seq:
            The sequence being checked.
        :param io.BufferedIOBase stream:
            The data stream to read from. Except in rare circumstances, this is
            the same stream that was passed to :meth:`.from_stream`. The stream
            pointer should be returned to its original position when the function
            exits.
        :param list values:
            A list of the objects that have been deserialized so far. In general
            this function *should not* modify the list. A possible exception to
            this rule is to remove a sentinel value from the end of the list.
        :param context:
            The ``context`` object passed to :meth:`.from_stream`.
        :param dict loaded_fields:
            The fields in the struct that have been loaded so far.

        :return: ``True`` if the deserializer should stop reading, ``False``
            otherwise.
        :rtype: bool
        """
    if seq.count is not None:
        return seq.get_final_element_count(loaded_fields) <= len(values)
    offset = stream.tell()
    try:
        return stream.read(1) == b''
    finally:
        stream.seek(offset)
