Extract a single frame from the data buffer.  The consumed
        data should be removed from the buffer.  If no complete frame
        can be read, must raise a ``NoFrames`` exception.

        :param data: A ``bytearray`` instance containing the data so
                     far read.
        :param state: An instance of ``FramerState``.  If the buffer
                      contains a partial frame, this object can be
                      used to store state information to allow the
                      remainder of the frame to be read.

        :returns: A frame.  The frame may be any object.  The stock
                  framers always return bytes.

def to_frame(self, data, state):
        """
        Extract a single frame from the data buffer.  The consumed
        data should be removed from the buffer.  If no complete frame
        can be read, must raise a ``NoFrames`` exception.

        :param data: A ``bytearray`` instance containing the data so
                     far read.
        :param state: An instance of ``FramerState``.  If the buffer
                      contains a partial frame, this object can be
                      used to store state information to allow the
                      remainder of the frame to be read.

        :returns: A frame.  The frame may be any object.  The stock
                  framers always return bytes.
        """

        # Convert the data to bytes
        frame = six.binary_type(data)

        # Clear the buffer
        del data[:]

        # Return the frame
        return frame